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
490e0689
Commit
490e0689
authored
5 years ago
by
Rhys Arkins
Browse files
Options
Downloads
Patches
Plain Diff
refactor(host-rules): cleaner got processing
parent
11c77d07
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/util/got/host-rules.js
+16
-12
16 additions, 12 deletions
lib/util/got/host-rules.js
with
16 additions
and
12 deletions
lib/util/got/host-rules.js
+
16
−
12
View file @
490e0689
/* eslint-disable no-param-reassign */
const
got
=
require
(
'
got
'
);
const
hostRules
=
require
(
'
../host-rules
'
);
...
...
@@ -7,26 +8,29 @@ const hostRules = require('../host-rules');
module
.
exports
=
got
.
create
({
options
:
{},
handler
:
(
options
,
next
)
=>
{
const
{
hostType
,
...
opts
}
=
options
;
if
(
!
options
.
hostname
)
{
return
next
(
opts
);
return
next
(
opt
ion
s
);
}
const
{
username
=
''
,
password
,
token
,
timeout
}
=
hostRules
.
find
({
hostType
,
const
{
username
,
password
,
token
,
timeout
}
=
hostRules
.
find
({
hostType
:
options
.
hostType
,
url
:
options
.
href
,
});
if
(
opts
.
headers
.
authorization
||
opts
.
auth
||
opts
.
token
)
{
logger
.
debug
(
'
Authorization already set for host:
'
+
opts
.
hostname
);
if
(
opt
ion
s
.
headers
.
authorization
||
opt
ion
s
.
auth
||
opt
ion
s
.
token
)
{
logger
.
trace
(
'
Authorization already set for host:
'
+
opt
ion
s
.
hostname
);
}
else
if
(
password
)
{
logger
.
debug
(
'
Applying Basic authentication for host
'
+
opts
.
hostname
);
opts
.
auth
=
`
${
username
}
:
${
password
}
`
;
logger
.
trace
(
'
Applying Basic authentication for host
'
+
options
.
hostname
);
options
.
auth
=
`
${
username
||
''
}
:
${
password
}
`
;
}
else
if
(
token
)
{
logger
.
debug
(
'
Applying Bearer authentication for host
'
+
opts
.
hostname
);
opts
.
token
=
token
;
logger
.
trace
(
'
Applying Bearer authentication for host
'
+
options
.
hostname
);
options
.
token
=
token
;
}
if
(
timeout
)
{
opts
.
gotTimeout
=
{
request
:
timeout
};
opt
ion
s
.
gotTimeout
=
{
request
:
timeout
};
}
return
next
(
opts
);
return
next
(
opt
ion
s
);
},
});
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