Skip to content

Commit 7775d95

Browse files
authored
Updates dependencies (#14)
1 parent 9b7ffd6 commit 7775d95

File tree

4 files changed

+33
-31
lines changed

4 files changed

+33
-31
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ jobs:
88
Lint:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v2
11+
- uses: actions/checkout@v4
1212
- run: npm install
1313
- run: npx xo
1414

1515
Build:
1616
runs-on: ubuntu-latest
1717
steps:
18-
- uses: actions/checkout@v2
18+
- uses: actions/checkout@v4
1919
- run: npm install
2020
- run: npm run build
2121

2222
Test:
2323
runs-on: ubuntu-latest
2424
steps:
25-
- uses: actions/checkout@v2
25+
- uses: actions/checkout@v4
2626
- run: npm install
2727
- run: npm run build
2828
- run: npx ava

index.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,26 @@ function getRawPatternRegex(matchPattern: string): string {
1515
throw new Error(matchPattern + ' is an invalid pattern, it must match ' + String(patternValidationRegex));
1616
}
1717

18-
let [, protocol, host, pathname] = matchPattern.split(/(^[^:]+:[/][/])([^/]+)?/);
18+
// Host undefined for file:///
19+
let [, protocol, host = '', pathname] = matchPattern.split(/(^[^:]+:[/][/])([^/]+)?/);
1920

20-
protocol = protocol
21+
protocol = protocol!
2122
.replace('*', isFirefox ? '(https?|wss?)' : 'https?') // Protocol wildcard
22-
.replace(/[/]/g, '[/]'); // Escape slashes
23-
24-
host = (host ?? '') // Undefined for file:///
25-
.replace(/^[*][.]/, '([^/]+.)*') // Initial wildcard
26-
.replace(/^[*]$/, '[^/]+') // Only wildcard
27-
.replace(/[.]/g, '[.]') // Escape dots
28-
.replace(/[*]$/g, '[^.]+'); // Last wildcard
29-
30-
pathname = pathname
31-
.replace(/[/]/g, '[/]') // Escape slashes
32-
.replace(/[.]/g, '[.]') // Escape dots
33-
.replace(/[*]/g, '.*'); // Any wildcard
23+
.replaceAll(/[/]/g, '[/]'); // Escape slashes
24+
25+
if (host === '*') {
26+
host = '[^/]+';
27+
} else if (host) {
28+
host = host
29+
.replace(/^[*][.]/, '([^/]+.)*') // Initial wildcard
30+
.replaceAll(/[.]/g, '[.]') // Escape dots
31+
.replace(/[*]$/, '[^.]+'); // Last wildcard
32+
}
33+
34+
pathname = pathname!
35+
.replaceAll(/[/]/g, '[/]') // Escape slashes
36+
.replaceAll(/[.]/g, '[.]') // Escape dots
37+
.replaceAll(/[*]/g, '.*'); // Any wildcard
3438

3539
return '^' + protocol + host + '(' + pathname + ')?$';
3640
}

package.json

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
"license": "MIT",
2222
"author": "Federico Brigante <[email protected]> (https://fregante.com)",
2323
"type": "module",
24-
"main": "index.js",
25-
"module": "index.js",
24+
"exports": "./index.js",
25+
"types": "./index.d.ts",
2626
"files": [
2727
"index.js",
2828
"index.d.ts"
@@ -48,13 +48,16 @@
4848
"escape-string-regexp": "^5.0.0"
4949
},
5050
"devDependencies": {
51-
"@sindresorhus/tsconfig": "^3.0.1",
52-
"@types/chrome": "0.0.210",
53-
"ava": "^5.1.1",
54-
"sinon": "^15.0.1",
55-
"type-fest": "^3.5.3",
56-
"typescript": "^4.9.4",
57-
"xo": "^0.53.1"
51+
"@sindresorhus/tsconfig": "^5.0.0",
52+
"@types/chrome": "0.0.256",
53+
"ava": "^6.0.1",
54+
"sinon": "^17.0.1",
55+
"type-fest": "^4.9.0",
56+
"typescript": "^5.3.3",
57+
"xo": "^0.56.0"
58+
},
59+
"engines": {
60+
"node": ">=18"
5861
},
5962
"webExt": {
6063
"sourceDir": "demo-extension",

tsconfig.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
{
22
"extends": "@sindresorhus/tsconfig",
3-
"compilerOptions": {
4-
"target": "es2018",
5-
"module": "es2015",
6-
"noUncheckedIndexedAccess": false
7-
},
83
"files": [
94
"index.ts"
105
]

0 commit comments

Comments
 (0)