diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index dce0ff59865d63..223da36102ff8a 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -1208,6 +1208,23 @@ A preset alternative to the above is: } ``` +To match specific ports you have to add a protocol to `matchHost`: + +```json +{ + "hostRules": [ + { + "matchHost": "https://domain.com:9118", + "enabled": false + } + ] +} +``` + + +!!! warning + Using `matchHost` without a protocol behaves the same as if you had set no `matchHost` configuration. + !!! note Disabling a host is only 100% effective if added to self-hosted config. diff --git a/lib/util/host-rules.spec.ts b/lib/util/host-rules.spec.ts index 6513bf9e50ac4c..d8c7dbd78ddf4a 100644 --- a/lib/util/host-rules.spec.ts +++ b/lib/util/host-rules.spec.ts @@ -235,6 +235,26 @@ describe('util/host-rules', () => { expect(find({ url: 'httpsdomain.com' }).token).toBeUndefined(); }); + it('matches on matchHost with port', () => { + add({ + matchHost: 'https://domain.com:9118', + token: 'def', + }); + expect(find({ url: 'https://domain.com:9118' }).token).toBe('def'); + expect(find({ url: 'https://domain.com' }).token).toBeUndefined(); + expect(find({ url: 'httpsdomain.com' }).token).toBeUndefined(); + }); + + it('host with port is interpreted as empty', () => { + add({ + matchHost: 'domain.com:9118', + token: 'def', + }); + expect(find({ url: 'https://domain.com:9118' }).token).toBe('def'); + expect(find({ url: 'https://domain.com' }).token).toBe('def'); + expect(find({ url: 'httpsdomain.com' }).token).toBe('def'); + }); + it('matches on hostType and endpoint', () => { add({ hostType: NugetDatasource.id,