File tree 3 files changed +25
-0
lines changed
packages/@vuepress/shared
3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { isLinkFtp } from '@vuepress/shared'
2
+
3
+ const testCases : [ string , ReturnType < typeof isLinkFtp > ] [ ] = [
4
+ [ 'ftp://foobar.com' , true ] ,
5
+ [ 'https://foobar.com' , false ] ,
6
+ [ 'http://foobar.com' , false ] ,
7
+ [ '//foobar.com' , false ] ,
8
+ [ 'foobar.com' , false ] ,
9
+ [ '/foo/bar' , false ] ,
10
+ ]
11
+
12
+ describe ( 'shared > isLinkFtp' , ( ) => {
13
+ describe ( 'should determine ftp link correctly' , ( ) => {
14
+ testCases . forEach ( ( [ source , expected ] ) => {
15
+ it ( `link: ${ source } ` , ( ) => {
16
+ expect ( isLinkFtp ( source ) ) . toBe ( expected )
17
+ } )
18
+ } )
19
+ } )
20
+ } )
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ export * from './formatDateString'
7
7
export * from './htmlEscape'
8
8
export * from './htmlUnescape'
9
9
export * from './isLinkExternal'
10
+ export * from './isLinkFtp'
10
11
export * from './isLinkHttp'
11
12
export * from './isLinkMailto'
12
13
export * from './isLinkTel'
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Determine a link is ftp link or not
3
+ */
4
+ export const isLinkFtp = ( link : string ) : boolean => link . startsWith ( 'ftp://' )
You can’t perform that action at this time.
0 commit comments