@@ -290,29 +290,50 @@ export class ProxyRules {
290290
291291 break ;
292292
293- case CompiledProxyRuleType . Exact :
293+ case CompiledProxyRuleType . SearchDomainSubdomainAndPath :
294294
295- if ( lowerCaseUrl == rule . search )
295+ if ( schemaLessUrlLowerCase == null ) {
296+ schemaLessUrlLowerCase = Utils . removeSchemaFromUrl ( lowerCaseUrl ) ;
297+ if ( schemaLessUrlLowerCase == null ) {
298+ continue ;
299+ }
300+ }
301+ if ( schemaLessUrlLowerCase . startsWith ( rule . search ) )
296302 return rule ;
297- break ;
298303
299- case CompiledProxyRuleType . RegexHost :
304+ let ruleSearchHost = Utils . extractHostNameFromInvalidUrl ( rule . search ) ;
305+ if ( ruleSearchHost != null ) {
300306
301- if ( domainHostLowerCase == null ) {
302- domainHostLowerCase = Utils . extractHostNameFromUrl ( lowerCaseUrl ) ;
303307 if ( domainHostLowerCase == null ) {
304- continue ;
308+ domainHostLowerCase = Utils . extractHostNameFromUrl ( lowerCaseUrl ) ;
309+ if ( domainHostLowerCase == null ) {
310+ continue ;
311+ }
305312 }
313+
314+ // should be the same
315+ if ( ruleSearchHost != domainHostLowerCase && ! domainHostLowerCase . endsWith ( '.' + ruleSearchHost ) )
316+ continue ;
317+
318+ // after this state, we are sure that the url is for the same domain, now just checking the path
306319 }
307320
308- if ( rule . regex . test ( domainHostLowerCase ) )
321+ // subdomains
322+ if ( schemaLessUrlLowerCase . includes ( '.' + rule . search ) )
309323 return rule ;
310324 break ;
311325
312- case CompiledProxyRuleType . RegexUrl :
313- // Using original url with case sensitivity
314- if ( rule . regex . test ( searchUrl ) )
326+ case CompiledProxyRuleType . SearchDomainAndPath :
327+
328+ if ( schemaLessUrlLowerCase == null ) {
329+ schemaLessUrlLowerCase = Utils . removeSchemaFromUrl ( lowerCaseUrl ) ;
330+ if ( schemaLessUrlLowerCase == null ) {
331+ continue ;
332+ }
333+ }
334+ if ( schemaLessUrlLowerCase . startsWith ( rule . search ) )
315335 return rule ;
336+
316337 break ;
317338
318339 case CompiledProxyRuleType . SearchUrl :
@@ -321,61 +342,40 @@ export class ProxyRules {
321342 return rule ;
322343 break ;
323344
324- case CompiledProxyRuleType . SearchDomain :
345+ case CompiledProxyRuleType . RegexUrl :
346+ // Using original url with case sensitivity
347+ if ( rule . regex . test ( searchUrl ) )
348+ return rule ;
349+ break ;
350+
351+ case CompiledProxyRuleType . RegexHost :
325352
326353 if ( domainHostLowerCase == null ) {
327354 domainHostLowerCase = Utils . extractHostNameFromUrl ( lowerCaseUrl ) ;
328355 if ( domainHostLowerCase == null ) {
329356 continue ;
330357 }
331358 }
332- if ( rule . search == domainHostLowerCase )
333- return rule ;
334- break ;
335-
336- case CompiledProxyRuleType . SearchDomainAndPath :
337359
338- if ( schemaLessUrlLowerCase == null ) {
339- schemaLessUrlLowerCase = Utils . removeSchemaFromUrl ( lowerCaseUrl ) ;
340- if ( schemaLessUrlLowerCase == null ) {
341- continue ;
342- }
343- }
344- if ( schemaLessUrlLowerCase . startsWith ( rule . search ) )
360+ if ( rule . regex . test ( domainHostLowerCase ) )
345361 return rule ;
346-
347362 break ;
348363
349- case CompiledProxyRuleType . SearchDomainSubdomainAndPath :
364+ case CompiledProxyRuleType . SearchDomain :
350365
351- if ( schemaLessUrlLowerCase == null ) {
352- schemaLessUrlLowerCase = Utils . removeSchemaFromUrl ( lowerCaseUrl ) ;
353- if ( schemaLessUrlLowerCase == null ) {
366+ if ( domainHostLowerCase == null ) {
367+ domainHostLowerCase = Utils . extractHostNameFromUrl ( lowerCaseUrl ) ;
368+ if ( domainHostLowerCase == null ) {
354369 continue ;
355370 }
356371 }
357- if ( schemaLessUrlLowerCase . startsWith ( rule . search ) )
372+ if ( rule . search == domainHostLowerCase )
358373 return rule ;
374+ break ;
359375
360- let ruleSearchHost = Utils . extractHostNameFromInvalidUrl ( rule . search ) ;
361- if ( ruleSearchHost != null ) {
362-
363- if ( domainHostLowerCase == null ) {
364- domainHostLowerCase = Utils . extractHostNameFromUrl ( lowerCaseUrl ) ;
365- if ( domainHostLowerCase == null ) {
366- continue ;
367- }
368- }
369-
370- // should be the same
371- if ( ruleSearchHost != domainHostLowerCase && ! domainHostLowerCase . endsWith ( '.' + ruleSearchHost ) )
372- continue ;
373-
374- // after this state, we are sure that the url is for the same domain, now just checking the path
375- }
376+ case CompiledProxyRuleType . Exact :
376377
377- // subdomains
378- if ( schemaLessUrlLowerCase . includes ( '.' + rule . search ) )
378+ if ( lowerCaseUrl == rule . search )
379379 return rule ;
380380 break ;
381381 }
@@ -408,18 +408,6 @@ export class ProxyRules {
408408
409409 break ;
410410
411- case CompiledProxyRuleType . RegexHost :
412-
413- if ( rule . regex . test ( domainHostLowerCase ) )
414- return rule ;
415- break ;
416-
417- case CompiledProxyRuleType . SearchDomain :
418-
419- if ( rule . search == domainHostLowerCase )
420- return rule ;
421- break ;
422-
423411 case CompiledProxyRuleType . SearchDomainSubdomainAndPath :
424412
425413 if ( schemaLessUrlLowerCase == null ) {
@@ -445,6 +433,18 @@ export class ProxyRules {
445433 return rule ;
446434 break ;
447435
436+ case CompiledProxyRuleType . RegexHost :
437+
438+ if ( rule . regex . test ( domainHostLowerCase ) )
439+ return rule ;
440+ break ;
441+
442+ case CompiledProxyRuleType . SearchDomain :
443+
444+ if ( rule . search == domainHostLowerCase )
445+ return rule ;
446+ break ;
447+
448448 case CompiledProxyRuleType . Exact :
449449 case CompiledProxyRuleType . RegexUrl :
450450 case CompiledProxyRuleType . SearchUrl :
0 commit comments