Skip to content

Commit 4e1e0d9

Browse files
authored
Merge pull request #60 from KnpLabs/change/add-support-for-wildcards-in-authorized-domains
Add support for wildcards in worker renderer authorized domains
2 parents d59c8c0 + 1905da9 commit 4e1e0d9

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ RUN apt-get update \
1313
&& apt-get update \
1414
&& apt-get install -y \
1515
procps=2:3.3.12-3+deb9u1 \
16-
google-chrome-stable=91.0.4472.101-1 \
16+
google-chrome-stable=91.0.4472.106-1 \
1717
fonts-ipafont-gothic=00303-16 \
1818
fonts-wqy-zenhei=0.9.45-6 \
1919
fonts-thai-tlwg=1:0.6.3-1 \

src/worker/renderers/chrome/browserRequestHandler.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ import { T, anyPass, complement, cond, equals, find, ifElse, isNil, pipe, replac
44
const resolveRequestDomain = req => req.url().match(/^(https?:\/\/)?(?<host>[^/]+)/).groups.host
55

66
// isMatchingDomain :: String -> String -> Boolean
7-
const isMatchingDomain = input => anyPass([
8-
equals('*'),
9-
value => test(new RegExp(`${value}$`, 'i'), input),
10-
])
7+
const isMatchingDomain = input => value =>
8+
test(new RegExp(`^${replace('*', '.*', value)}$`, 'i'), input)
119

1210
// isRequestDomainAuthorized :: [String] -> Request -> Boolean
1311
const isRequestDomainAuthorized = authorizedRequestDomains => pipe(

src/worker/renderers/chrome/browserRequestHandler.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ describe('worker :: renderer :: browserRequestHandler', () => {
7979
const configuration = {
8080
worker: {
8181
renderer: {
82-
authorized_request_domains: ['example.com'],
82+
authorized_request_domains: ['*.example.com'],
8383
authorized_request_resources: ['*'],
8484
redirections: [],
8585
},
@@ -150,7 +150,7 @@ describe('worker :: renderer :: browserRequestHandler', () => {
150150
const configuration = {
151151
worker: {
152152
renderer: {
153-
authorized_request_domains: ['example.com'],
153+
authorized_request_domains: ['*.example.com'],
154154
authorized_request_resources: ['document'],
155155
redirections: [],
156156
},

0 commit comments

Comments
 (0)