@@ -108,11 +108,7 @@ export default class Match<T> {
108108 return `${ re . replace ( / \/ / g, "/" ) } $` ;
109109 }
110110
111- public add ( url : string , val : T ) {
112- const re = this . compileRe ( url ) ;
113- if ( ! re ) {
114- throw new Error ( `invalid url: ${ url } ` ) ;
115- }
111+ addRegex ( re : string , val : T ) {
116112 let rule = this . rule . get ( re ) ;
117113 if ( ! rule ) {
118114 rule = [ ] ;
@@ -123,6 +119,19 @@ export default class Match<T> {
123119 this . delCache ( ) ;
124120 }
125121
122+ public add ( url : string , val : T ) {
123+ // ε€ζζ―δΈζ―δΈδΈͺζ£ε
124+ if ( url . startsWith ( "/^" ) || url . endsWith ( "$/" ) ) {
125+ this . addRegex ( url , val ) ;
126+ }
127+ const re = this . compileRe ( url ) ;
128+ if ( ! re ) {
129+ console . warn ( "bad match rule" , { url, val } ) ;
130+ return ;
131+ }
132+ this . addRegex ( re , val ) ;
133+ }
134+
126135 public match ( url : string ) : T [ ] {
127136 let ret = this . cache . get ( url ) ;
128137 if ( ret ) {
@@ -231,6 +240,14 @@ export function parsePatternMatchesURL(
231240 exclude ?: boolean ;
232241 }
233242) : PatternMatchesUrl | undefined {
243+ // ε¦ζζ―ζ£εοΌε€ηζιι
244+ if ( url . startsWith ( "/^" ) || url . endsWith ( "$/" ) ) {
245+ return {
246+ scheme : "*" ,
247+ host : "*" ,
248+ path : "*" ,
249+ } ;
250+ }
234251 let result : PatternMatchesUrl | undefined ;
235252 const match = / ^ ( .+ ?) : \/ \/ ( .* ?) ( \/ ( .* ?) ( \? .* ?| ) | ) $ / . exec ( url ) ;
236253 if ( match ) {
0 commit comments