Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
renovate
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
Renovate Bot
renovate
Commits
8fb9197d
Unverified
Commit
8fb9197d
authored
3 years ago
by
David Straub
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
fix(host-rules): support matchHost with a dot prefix (#11523)
Co-authored-by:
Rhys Arkins
<
rhys@arkins.net
>
parent
f9f4d29a
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
docs/usage/configuration-options.md
+2
-0
2 additions, 0 deletions
docs/usage/configuration-options.md
lib/util/host-rules.spec.ts
+9
-0
9 additions, 0 deletions
lib/util/host-rules.spec.ts
lib/util/host-rules.ts
+4
-1
4 additions, 1 deletion
lib/util/host-rules.ts
with
15 additions
and
1 deletion
docs/usage/configuration-options.md
+
2
−
0
View file @
8fb9197d
...
@@ -1024,6 +1024,8 @@ Example:
...
@@ -1024,6 +1024,8 @@ Example:
This can be a base URL (e.g.
`https://api.github.com`
) or a hostname like
`github.com`
or
`api.github.com`
.
This can be a base URL (e.g.
`https://api.github.com`
) or a hostname like
`github.com`
or
`api.github.com`
.
If the value starts with
`http(s)`
then it will only match against URLs which start with the full base URL.
If the value starts with
`http(s)`
then it will only match against URLs which start with the full base URL.
Otherwise, it will be matched by checking if the URL's hostname matches the
`matchHost`
directly or ends with it.
Otherwise, it will be matched by checking if the URL's hostname matches the
`matchHost`
directly or ends with it.
When checking the end of the hostname, a single dot is prefixed to the value of
`matchHost`
, if one is not
already present, to ensure it can only match against whole domain segments.
### timeout
### timeout
...
...
This diff is collapsed.
Click to expand it.
lib/util/host-rules.spec.ts
+
9
−
0
View file @
8fb9197d
...
@@ -208,6 +208,15 @@ describe('util/host-rules', () => {
...
@@ -208,6 +208,15 @@ describe('util/host-rules', () => {
expect
(
find
({
url
:
'
https://domain.com
'
}).
token
).
toEqual
(
'
def
'
);
expect
(
find
({
url
:
'
https://domain.com
'
}).
token
).
toEqual
(
'
def
'
);
expect
(
find
({
url
:
'
httpsdomain.com
'
}).
token
).
toBeUndefined
();
expect
(
find
({
url
:
'
httpsdomain.com
'
}).
token
).
toBeUndefined
();
});
});
it
(
'
matches on matchHost with dot prefix
'
,
()
=>
{
add
({
matchHost
:
'
.domain.com
'
,
token
:
'
def
'
,
});
expect
(
find
({
url
:
'
https://api.domain.com
'
}).
token
).
toEqual
(
'
def
'
);
expect
(
find
({
url
:
'
https://domain.com
'
}).
token
).
toBeUndefined
();
expect
(
find
({
url
:
'
httpsdomain.com
'
}).
token
).
toBeUndefined
();
});
it
(
'
matches on hostType and endpoint
'
,
()
=>
{
it
(
'
matches on hostType and endpoint
'
,
()
=>
{
add
({
add
({
hostType
:
datasourceNuget
.
id
,
hostType
:
datasourceNuget
.
id
,
...
...
This diff is collapsed.
Click to expand it.
lib/util/host-rules.ts
+
4
−
1
View file @
8fb9197d
...
@@ -85,7 +85,10 @@ function matchesHost(rule: HostRule, search: HostRuleSearch): boolean {
...
@@ -85,7 +85,10 @@ function matchesHost(rule: HostRule, search: HostRuleSearch): boolean {
return
false
;
return
false
;
}
}
const
{
hostname
}
=
parsedUrl
;
const
{
hostname
}
=
parsedUrl
;
return
hostname
===
rule
.
matchHost
||
hostname
.
endsWith
(
`.
${
rule
.
matchHost
}
`
);
const
dotPrefixedMatchHost
=
rule
.
matchHost
.
startsWith
(
'
.
'
)
?
rule
.
matchHost
:
`.
${
rule
.
matchHost
}
`
;
return
hostname
===
rule
.
matchHost
||
hostname
.
endsWith
(
dotPrefixedMatchHost
);
}
}
export
function
find
(
search
:
HostRuleSearch
):
HostRule
{
export
function
find
(
search
:
HostRuleSearch
):
HostRule
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment