Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'route-link' into auto-link
- Loading branch information
Showing
6 changed files
with
193 additions
and
204 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
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 |
---|---|---|
@@ -1,23 +1,13 @@ | ||
import { isLinkHttp } from './isLinkHttp.js' | ||
import { isLinkWithProtocol } from './isLinkWithProtocol.js' | ||
|
||
const markdownLinkRegexp = /.md((\?|#).*)?$/ | ||
|
||
/** | ||
* Determine a link is external or not | ||
*/ | ||
export const isLinkExternal = (link: string, base = '/'): boolean => { | ||
if (isLinkHttp(link)) { | ||
return true | ||
} | ||
|
||
export const isLinkExternal = (link: string, base = '/'): boolean => | ||
isLinkWithProtocol(link) || | ||
// absolute link that does not start with `base` and does not end with `.md` | ||
if ( | ||
link.startsWith('/') && | ||
(link.startsWith('/') && | ||
!link.startsWith(base) && | ||
!markdownLinkRegexp.test(link) | ||
) { | ||
return true | ||
} | ||
|
||
return false | ||
} | ||
!markdownLinkRegexp.test(link)) |
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
Oops, something went wrong.