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
79de1b1e
Commit
79de1b1e
authored
7 years ago
by
Rhys Arkins
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Use npm Registry Filter Header (#249)
Closes #245
parent
f5a92e80
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
lib/api/npm.js
+3
-0
3 additions, 0 deletions
lib/api/npm.js
test/api/__snapshots__/npm.spec.js.snap
+26
-0
26 additions, 0 deletions
test/api/__snapshots__/npm.spec.js.snap
test/api/npm.spec.js
+2
-13
2 additions, 13 deletions
test/api/npm.spec.js
with
31 additions
and
13 deletions
lib/api/npm.js
+
3
−
0
View file @
79de1b1e
...
...
@@ -19,6 +19,9 @@ async function getDependency(name) {
const
authInfo
=
registryAuthToken
(
regUrl
);
const
headers
=
{};
// Reduce metadata https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md
headers
.
accept
=
'
application/vnd.npm.install-v1+json
'
;
if
(
authInfo
)
{
headers
.
authorization
=
`
${
authInfo
.
type
}
${
authInfo
.
token
}
`
;
}
...
...
This diff is collapsed.
Click to expand it.
test/api/__snapshots__/npm.spec.js.snap
0 → 100644
+
26
−
0
View file @
79de1b1e
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`api/npm should fetch package info from npm 1`] = `
Array [
"https://npm.mycustomregistry.com/foobar",
Object {
"headers": Object {
"accept": "application/vnd.npm.install-v1+json",
},
"json": true,
},
]
`;
exports[`api/npm should send an authorization header if provided 1`] = `
Array [
"https://npm.mycustomregistry.com/foobar",
Object {
"headers": Object {
"accept": "application/vnd.npm.install-v1+json",
"authorization": "Basic 1234",
},
"json": true,
},
]
`;
This diff is collapsed.
Click to expand it.
test/api/npm.spec.js
+
2
−
13
View file @
79de1b1e
...
...
@@ -17,10 +17,7 @@ describe('api/npm', () => {
const
res
=
await
npm
.
getDependency
(
'
foobar
'
);
expect
(
res
).
toMatchObject
({
some
:
'
data
'
});
const
call
=
got
.
mock
.
calls
[
0
];
expect
(
call
).
toMatchObject
([
'
https://npm.mycustomregistry.com/foobar
'
,
{
json
:
true
,
headers
:
{}
},
]);
expect
(
call
).
toMatchSnapshot
();
});
it
(
'
should send an authorization header if provided
'
,
async
()
=>
{
registryUrl
.
mockImplementation
(()
=>
'
https://npm.mycustomregistry.com/
'
);
...
...
@@ -32,14 +29,6 @@ describe('api/npm', () => {
const
res
=
await
npm
.
getDependency
(
'
foobar
'
);
expect
(
res
).
toMatchObject
({
some
:
'
data
'
});
const
call
=
got
.
mock
.
calls
[
0
];
expect
(
call
).
toMatchObject
([
'
https://npm.mycustomregistry.com/foobar
'
,
{
json
:
true
,
headers
:
{
authorization
:
'
Basic 1234
'
,
},
},
]);
expect
(
call
).
toMatchSnapshot
();
});
});
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