Skip to content

Commit

Permalink
docs(hostRules): document current matchHost behaviour if a port is su…
Browse files Browse the repository at this point in the history
…pplied (#22007)

Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
  • Loading branch information
secustor and HonkingGoose committed May 18, 2023
1 parent d4b3504 commit 7cfd714
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/usage/configuration-options.md
Expand Up @@ -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
}
]
}
```

<!-- prettier-ignore -->
!!! warning
Using `matchHost` without a protocol behaves the same as if you had set no `matchHost` configuration.

<!-- prettier-ignore -->
!!! note
Disabling a host is only 100% effective if added to self-hosted config.
Expand Down
20 changes: 20 additions & 0 deletions lib/util/host-rules.spec.ts
Expand Up @@ -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,
Expand Down

0 comments on commit 7cfd714

Please sign in to comment.