Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(hostRules): document current matchHost behaviour if a port is supplied #22007

Merged
merged 2 commits into from May 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/usage/configuration-options.md
Expand Up @@ -1190,6 +1190,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
secustor marked this conversation as resolved.
Show resolved Hide resolved
}
]
}
```

<!-- prettier-ignore -->
!!! warning
Using `matchHost` without a protocol will lead to a behaviour as there is no `matchHost` configuration at all.
secustor marked this conversation as resolved.
Show resolved Hide resolved

<!-- 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', () => {
secustor marked this conversation as resolved.
Show resolved Hide resolved
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