File tree Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -62,4 +62,4 @@ function test() {
62
62
console . log ( result ) ;
63
63
}
64
64
65
- test ( ) ;
65
+ // test();
Original file line number Diff line number Diff line change @@ -18,3 +18,6 @@ import object from '../object'
18
18
19
19
// designPattern
20
20
import designPattern from "../designPattern"
21
+
22
+ // url parser
23
+ import url from "../url"
Original file line number Diff line number Diff line change 1
- export const parser = {
1
+ export const Url = {
2
2
parse ( url ) {
3
3
let ret = { } ;
4
-
4
+ // []中的 ^ 表示取非, 这里[^:]代表取非 : 的字符
5
5
let regex = / ^ ( [ ^ : ] + ) : \/ \/ ( [ ^ \/ ] + ) ( .* ) $ / ; //protocol, login, urlpath
6
6
let result = regex . exec ( url ) ;
7
7
@@ -63,3 +63,18 @@ export const parser = {
63
63
return 0 ;
64
64
}
65
65
} ;
66
+ // test
67
+ ( ( ) => {
68
+ let result
69
+ result = Url . parse ( 'http://localhost:8080/' ) ;
70
+ console . log ( result )
71
+
72
+ result = Url . parse ( '^://localhost:8080/' ) ;
73
+ console . log ( result )
74
+
75
+ result = Url . isAbsolute ( '://localhost:8080/' ) ;
76
+ console . log ( result )
77
+
78
+ debugger ;
79
+
80
+ } ) ( window )
You can’t perform that action at this time.
0 commit comments