File tree 2 files changed +32
-2
lines changed 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,11 @@ bool isHrefALibrary(String? href) {
17
17
if (href.endsWith ('.html' )) {
18
18
return false ;
19
19
}
20
- // libraries have no slash in their hrefs
21
- return ! href.contains ('/' );
20
+ final segments = href.split ('/' );
21
+ // remove if the last segment is empty, indicating a trailing slash
22
+ if (segments.last.isEmpty) {
23
+ segments.removeLast ();
24
+ }
25
+ // libraries have only a single segment
26
+ return segments.length == 1 ;
22
27
}
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
2
+ // for details. All rights reserved. Use of this source code is governed by a
3
+ // BSD-style license that can be found in the LICENSE file.
4
+
5
+ import 'package:pana/src/dartdoc/dartdoc_internals.dart' ;
6
+ import 'package:test/test.dart' ;
7
+
8
+ void main () {
9
+ group ('dartdoc internals' , () {
10
+ test ('isHrefALibrary: negative' , () async {
11
+ expect (isHrefALibrary (null ), false );
12
+ expect (isHrefALibrary ('' ), false );
13
+ expect (isHrefALibrary ('index.html' ), false );
14
+ expect (isHrefALibrary ('retry.html' ), false );
15
+ expect (isHrefALibrary ('retry/retry.html' ), false );
16
+ expect (isHrefALibrary ('a/b' ), false );
17
+ });
18
+
19
+ test ('isHrefALibrary: positive' , () async {
20
+ expect (isHrefALibrary ('x/x-library.html' ), true );
21
+ expect (isHrefALibrary ('x' ), true );
22
+ expect (isHrefALibrary ('x/' ), true );
23
+ });
24
+ });
25
+ }
You can’t perform that action at this time.
0 commit comments