-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better structure for the is-library-detection code. (#1423)
- Loading branch information
Showing
3 changed files
with
28 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// Infers whether a dartdoc href is a link to a library page. | ||
/// - pre-8.3.0 the file ended with `-library.html` | ||
/// - with 8.3.0 the reference is a top-level directory with no slash in it | ||
bool isHrefALibrary(String? href) { | ||
if (href == null || href.isEmpty) { | ||
return false; | ||
} | ||
// libraries before 8.3 | ||
if (href.endsWith('-library.html')) { | ||
return true; | ||
} | ||
// libraries after 8.3 do not have the .html suffix in their href | ||
if (href.endsWith('.html')) { | ||
return false; | ||
} | ||
// libraries have no slash in their hrefs | ||
return !href.contains('/'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters