Skip to content

Commit

Permalink
Match apex domain with *.domain.com
Browse files Browse the repository at this point in the history
Fixes #2
  • Loading branch information
fregante committed Dec 18, 2020
1 parent c7ea521 commit 72ad4af
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ function getRawRegex(matchPattern: string): string {
.replace(/[/]/g, '[/]'); // Escape slashes

host = (host ?? '') // Undefined for file:///
.replace(/^[*][.]/, '([^/]+.)*') // Initial wildcard
.replace(/^[*]$/, '[^/]+') // Only wildcard
.replace(/[.]/g, '[.]') // Escape dots
.replace(/^[*]/, '[^/]+') // Initial or only wildcard
.replace(/[*]$/g, '[^.]+'); // Last wildcard

pathname = pathname
Expand Down
1 change: 1 addition & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ map.set('http://*/foo*', [
map.set('https://*.google.com/foo*bar', [
'https://www.google.com/foo/baz/bar',
'https://docs.google.com/foobar',
'https://google.com/foonderbar',
]);
map.set('http://example.org/foo/bar.html', [
'http://example.org/foo/bar.html',
Expand Down

0 comments on commit 72ad4af

Please sign in to comment.