File tree Expand file tree Collapse file tree 8 files changed +527
-528
lines changed
webpack/plugin-extension/feature-web-resources Expand file tree Collapse file tree 8 files changed +527
-528
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ export default [
16
16
ignores : [
17
17
'__TEST__' ,
18
18
'**/dist/' ,
19
+ '**/e2e-report/' ,
19
20
'**/webpack.config.js' ,
20
21
'**/postcss.config.js' ,
21
22
'**/tailwind.config.js' ,
Original file line number Diff line number Diff line change 9
9
"node" : " >=18"
10
10
},
11
11
"name" : " extension" ,
12
- "version" : " 2.0.0-alpha.26 " ,
12
+ "version" : " 2.0.0-alpha.28 " ,
13
13
"description" : " Create cross-browser extensions with no build configuration." ,
14
14
"main" : " ./dist/cli.js" ,
15
15
"types" : " ./dist/cli.d.ts" ,
Original file line number Diff line number Diff line change 9
9
"node" : " >=18"
10
10
},
11
11
"name" : " extension-create" ,
12
- "version" : " 2.0.0-alpha.26 " ,
12
+ "version" : " 2.0.0-alpha.28 " ,
13
13
"description" : " The Extension.js create step" ,
14
14
"main" : " ./dist/module.js" ,
15
15
"types" : " ./dist/module.d.ts" ,
Original file line number Diff line number Diff line change 9
9
"node" : " >=18"
10
10
},
11
11
"name" : " extension-develop" ,
12
- "version" : " 2.0.0-alpha.26 " ,
12
+ "version" : " 2.0.0-alpha.28 " ,
13
13
"description" : " The develop step of Extension.js" ,
14
14
"main" : " ./dist/module.js" ,
15
15
"types" : " ./dist/module.d.ts" ,
Original file line number Diff line number Diff line change 1
-
2
- import { cleanMatches } from "../clean-matches" ;
1
+ import { cleanMatches } from '../clean-matches'
3
2
4
3
describe ( 'cleanMatches' , ( ) => {
5
4
it ( 'does not handle non-urls' , ( ) => {
6
- expect ( cleanMatches ( [ '<all_urls>' ] ) ) . toEqual ( [ '<all_urls>' ] ) ;
7
- } ) ;
5
+ expect ( cleanMatches ( [ '<all_urls>' ] ) ) . toEqual ( [ '<all_urls>' ] )
6
+ } )
8
7
9
8
it ( 'handles wildcards' , ( ) => {
10
9
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
+ } )
20
13
21
14
it ( 'cleans up all types of pathnames' , ( ) => {
22
15
expect (
23
16
cleanMatches ( [
24
17
'https://example.com' ,
25
18
'https://example.com/some/path/*' ,
26
- 'https://example.com/some/path' ,
19
+ 'https://example.com/some/path'
27
20
] )
28
21
) . toEqual ( [
29
22
'https://example.com/*' ,
30
23
'https://example.com/*' ,
31
- 'https://example.com/*' ,
32
- ] ) ;
33
- } ) ;
34
- } ) ;
24
+ 'https://example.com/*'
25
+ ] )
26
+ } )
27
+ } )
Original file line number Diff line number Diff line change 1
-
2
1
/**
3
2
* From the docs at https://developer.chrome.com/docs/extensions/reference/manifest/web-accessible-resources#manifest_declaration
4
3
* > Google Chrome emits an "Invalid match pattern" error if the pattern has a path other than '/*'.
5
- *
4
+ *
6
5
* We need to ensure that paths are cleaned up from the matches to avoid this error.
7
6
*/
8
7
export function cleanMatches ( matches : string [ ] ) {
9
- return matches . map ( match => {
8
+ return matches . map ( ( match ) => {
10
9
try {
11
10
const url = new URL (
12
11
// Using a wildcard for the scheme (`*://`) is supported, but URL cannot parse it
13
12
match . replace ( / ^ \* : \/ \/ / , 'https://' )
14
- ) ;
13
+ )
15
14
16
15
// URL.pathname will return `/` even if the URL is just `https://example.com`
17
16
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 ) } /*`
19
18
} else if ( url . pathname === '/' ) {
20
- return `${ match } /*` ;
19
+ return `${ match } /*`
21
20
}
22
21
23
- return match ;
22
+ return match
24
23
} catch {
25
24
// Special cases like <all_urls> will fail the URL parse, but we can ignore them
26
- return match ;
25
+ return match
27
26
}
28
27
} )
29
28
}
Original file line number Diff line number Diff line change 5
5
type Manifest
6
6
} from '../../webpack-types'
7
7
import * as utils from '../../lib/utils'
8
- import { cleanMatches } from './clean-matches'
8
+ import { cleanMatches } from './clean-matches'
9
9
10
10
/**
11
11
* ResourcesPlugin is responsible for adding resources required
@@ -67,7 +67,7 @@ export class WebResourcesPlugin {
67
67
) ,
68
68
// We pass `matches` from `content_scripts` to `web_accessible_resources`,
69
69
// but `web_accessible_resources` has stricter rules, so we need to sanitize them
70
- matches : cleanMatches ( matches ) ,
70
+ matches : cleanMatches ( matches )
71
71
} )
72
72
}
73
73
} else {
You can’t perform that action at this time.
0 commit comments