File tree 2 files changed +4
-2
lines changed
client/theme-default/composables 2 files changed +4
-2
lines changed Original file line number Diff line number Diff line change 1
1
import { computed } from 'vue'
2
2
import { useData } from 'vitepress'
3
3
import type { DefaultTheme } from '../config'
4
+ import { EXTERNAL_URL_RE } from '../../shared'
4
5
5
6
export const platforms = [ 'GitHub' , 'GitLab' , 'Bitbucket' ] . map ( ( platform ) => {
6
7
return [ platform , new RegExp ( platform , 'i' ) ] as const
@@ -26,7 +27,7 @@ export function useRepo() {
26
27
27
28
function getRepoUrl ( repo : string ) : string {
28
29
// if the full url is not provided, default to GitHub repo
29
- return / ^ h t t p s ? : / . test ( repo ) ? repo : `https://github.com/${ repo } `
30
+ return EXTERNAL_URL_RE . test ( repo ) ? repo : `https://github.com/${ repo } `
30
31
}
31
32
32
33
function getRepoText ( url : string , text ?: string ) : string {
Original file line number Diff line number Diff line change 5
5
import MarkdownIt from 'markdown-it'
6
6
import { MarkdownParsedData } from '../markdown'
7
7
import { URL } from 'url'
8
+ import { EXTERNAL_URL_RE } from '../../shared'
8
9
9
10
const indexRE = / ( ^ | .* \/ ) i n d e x .m d ( # ? .* ) $ / i
10
11
@@ -18,7 +19,7 @@ export const linkPlugin = (
18
19
if ( hrefIndex >= 0 ) {
19
20
const hrefAttr = token . attrs ! [ hrefIndex ]
20
21
const url = hrefAttr [ 1 ]
21
- const isExternal = / ^ h t t p s ? : / . test ( url )
22
+ const isExternal = EXTERNAL_URL_RE . test ( url )
22
23
if ( isExternal ) {
23
24
Object . entries ( externalAttrs ) . forEach ( ( [ key , val ] ) => {
24
25
token . attrSet ( key , val )
You can’t perform that action at this time.
0 commit comments