Skip to content

Commit e57da96

Browse files
committed
v2.0.0-alpha.28
1 parent 85d2bc0 commit e57da96

File tree

8 files changed

+527
-528
lines changed

8 files changed

+527
-528
lines changed

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export default [
1616
ignores: [
1717
'__TEST__',
1818
'**/dist/',
19+
'**/e2e-report/',
1920
'**/webpack.config.js',
2021
'**/postcss.config.js',
2122
'**/tailwind.config.js',

pnpm-lock.yaml

Lines changed: 503 additions & 497 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

programs/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"node": ">=18"
1010
},
1111
"name": "extension",
12-
"version": "2.0.0-alpha.26",
12+
"version": "2.0.0-alpha.28",
1313
"description": "Create cross-browser extensions with no build configuration.",
1414
"main": "./dist/cli.js",
1515
"types": "./dist/cli.d.ts",

programs/create/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"node": ">=18"
1010
},
1111
"name": "extension-create",
12-
"version": "2.0.0-alpha.26",
12+
"version": "2.0.0-alpha.28",
1313
"description": "The Extension.js create step",
1414
"main": "./dist/module.js",
1515
"types": "./dist/module.d.ts",

programs/develop/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"node": ">=18"
1010
},
1111
"name": "extension-develop",
12-
"version": "2.0.0-alpha.26",
12+
"version": "2.0.0-alpha.28",
1313
"description": "The develop step of Extension.js",
1414
"main": "./dist/module.js",
1515
"types": "./dist/module.d.ts",
Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,27 @@
1-
2-
import { cleanMatches } from "../clean-matches";
1+
import {cleanMatches} from '../clean-matches'
32

43
describe('cleanMatches', () => {
54
it('does not handle non-urls', () => {
6-
expect(cleanMatches(['<all_urls>'])).toEqual(['<all_urls>']);
7-
});
5+
expect(cleanMatches(['<all_urls>'])).toEqual(['<all_urls>'])
6+
})
87

98
it('handles wildcards', () => {
109
expect(
11-
cleanMatches([
12-
'*://*/some/path',
13-
'https://*.google.com/foo*bar',
14-
])
15-
).toEqual([
16-
'*://*/*',
17-
'https://*.google.com/*',
18-
]);
19-
});
10+
cleanMatches(['*://*/some/path', 'https://*.google.com/foo*bar'])
11+
).toEqual(['*://*/*', 'https://*.google.com/*'])
12+
})
2013

2114
it('cleans up all types of pathnames', () => {
2215
expect(
2316
cleanMatches([
2417
'https://example.com',
2518
'https://example.com/some/path/*',
26-
'https://example.com/some/path',
19+
'https://example.com/some/path'
2720
])
2821
).toEqual([
2922
'https://example.com/*',
3023
'https://example.com/*',
31-
'https://example.com/*',
32-
]);
33-
});
34-
});
24+
'https://example.com/*'
25+
])
26+
})
27+
})
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
1-
21
/**
32
* From the docs at https://developer.chrome.com/docs/extensions/reference/manifest/web-accessible-resources#manifest_declaration
43
* > Google Chrome emits an "Invalid match pattern" error if the pattern has a path other than '/*'.
5-
*
4+
*
65
* We need to ensure that paths are cleaned up from the matches to avoid this error.
76
*/
87
export function cleanMatches(matches: string[]) {
9-
return matches.map(match => {
8+
return matches.map((match) => {
109
try {
1110
const url = new URL(
1211
// Using a wildcard for the scheme (`*://`) is supported, but URL cannot parse it
1312
match.replace(/^\*:\/\//, 'https://')
14-
);
13+
)
1514

1615
// URL.pathname will return `/` even if the URL is just `https://example.com`
1716
if (match.endsWith(url.pathname)) {
18-
return `${match.substring(0, match.length - url.pathname.length)}/*`;
17+
return `${match.substring(0, match.length - url.pathname.length)}/*`
1918
} else if (url.pathname === '/') {
20-
return `${match}/*`;
19+
return `${match}/*`
2120
}
2221

23-
return match;
22+
return match
2423
} catch {
2524
// Special cases like <all_urls> will fail the URL parse, but we can ignore them
26-
return match;
25+
return match
2726
}
2827
})
2928
}

programs/develop/webpack/plugin-extension/feature-web-resources/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
type Manifest
66
} from '../../webpack-types'
77
import * as utils from '../../lib/utils'
8-
import { cleanMatches } from './clean-matches'
8+
import {cleanMatches} from './clean-matches'
99

1010
/**
1111
* ResourcesPlugin is responsible for adding resources required
@@ -67,7 +67,7 @@ export class WebResourcesPlugin {
6767
),
6868
// We pass `matches` from `content_scripts` to `web_accessible_resources`,
6969
// but `web_accessible_resources` has stricter rules, so we need to sanitize them
70-
matches: cleanMatches(matches),
70+
matches: cleanMatches(matches)
7171
})
7272
}
7373
} else {

0 commit comments

Comments
 (0)