Skip to content

Commit 88125b2

Browse files
Support arrays of domains for patching settings (#506)
1 parent 8f9ab45 commit 88125b2

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/content-feature.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ export default class ContentFeature {
147147
if (!domain) return []
148148
const domains = this._getFeatureSetting()?.[featureKeyName] || []
149149
return domains.filter((rule) => {
150+
if (Array.isArray(rule.domain)) {
151+
return rule.domain.some((domainRule) => {
152+
return matchHostname(domain, domainRule)
153+
})
154+
}
150155
return matchHostname(domain, rule.domain)
151156
})
152157
}

unit-test/content-feature.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ describe('Helpers checks', () => {
88
expect(this.getFeatureSetting('test')).toBe('enabled3')
99
expect(this.getFeatureSetting('otherTest')).toBe('enabled')
1010
expect(this.getFeatureSetting('otherOtherTest')).toBe('ding')
11+
expect(this.getFeatureSetting('arrayTest')).toBe('enabledArray')
1112
didRun = true
1213
}
1314
}
@@ -21,6 +22,7 @@ describe('Helpers checks', () => {
2122
test: 'enabled',
2223
otherTest: 'disabled',
2324
otherOtherTest: 'ding',
25+
arrayTest: 'enabled',
2426
domains: [
2527
{
2628
domain: 'example.com',
@@ -34,6 +36,12 @@ describe('Helpers checks', () => {
3436
patchSettings: [
3537
{ op: 'replace', path: '/test', value: 'enabled3' }
3638
]
39+
},
40+
{
41+
domain: ['meep.com', 'example.com'],
42+
patchSettings: [
43+
{ op: 'replace', path: '/arrayTest', value: 'enabledArray' }
44+
]
3745
}
3846
]
3947
}

0 commit comments

Comments
 (0)