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

fix: avoid setting body for GET requests #3643

Merged
merged 4 commits into from Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
35 changes: 33 additions & 2 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -20,7 +20,7 @@
},
"dependencies": {
"@verdaccio/config": "6.0.0-6-next.61",
"@verdaccio/core": "6.0.0-6-next.61",
"@verdaccio/core": "6.0.0-6-next.62",
"@verdaccio/local-storage": "10.3.1",
"@verdaccio/logger-7": "6.0.0-6-next.6",
"@verdaccio/middleware": "6.0.0-6-next.40",
Expand All @@ -39,12 +39,14 @@
"debug": "^4.3.4",
"envinfo": "7.8.1",
"express": "4.18.2",
"express-rate-limit": "5.5.1",
"fast-safe-stringify": "2.1.1",
"handlebars": "4.7.7",
"js-yaml": "4.1.0",
"jsonwebtoken": "9.0.0",
"kleur": "4.1.5",
"lodash": "4.17.21",
"lru-cache": "7.17.0",
"lunr-mutable-indexes": "2.3.2",
"mime": "3.0.0",
"mkdirp": "1.0.4",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/up-storage.ts
Expand Up @@ -215,7 +215,7 @@ class ProxyStorage implements IProxy {
}
}
: undefined;
let requestOptions = {
let requestOptions: request.OptionsWithUrl = {
url: uri,
method: method,
headers: headers,
Expand Down
18 changes: 14 additions & 4 deletions test/unit/modules/uplinks/up-storage.spec.ts
Expand Up @@ -12,7 +12,7 @@ import configExample from '../../partials/config';

setup({});

describe('UpStorge', () => {
describe('UpStorage', () => {
const mockServerPort = 55547;
let mockRegistry;
const uplinkDefault = {
Expand All @@ -39,7 +39,7 @@ describe('UpStorge', () => {
expect(proxy).toBeDefined();
});

describe('UpStorge::getRemoteMetadata', () => {
describe('UpStorage::getRemoteMetadata', () => {
test('should be get remote metadata', (done) => {
const proxy = generateProxy();

Expand Down Expand Up @@ -72,9 +72,19 @@ describe('UpStorge', () => {
done();
});
});

test('should be get remote metadata with json when uplink is npmmirror', (done) => {
const proxy = generateProxy({ url: 'https://registry.npmmirror.com' });

proxy.getRemoteMetadata('jquery', { json: true }, (err, data) => {
expect(err).toBeNull();
expect(data.name).toBe('jquery');
done();
});
});
});

describe('UpStorge::fetchTarball', () => {
describe('UpStorage::fetchTarball', () => {
test('should fetch a tarball from uplink', (done) => {
const proxy = generateProxy();
const tarball = `http://${DOMAIN_SERVERS}:${mockServerPort}/jquery/-/jquery-1.5.1.tgz`;
Expand Down Expand Up @@ -147,7 +157,7 @@ describe('UpStorge', () => {
}, 10000);
});

describe('UpStorge::isUplinkValid', () => {
describe('UpStorage::isUplinkValid', () => {
describe('valid use cases', () => {
const validateUpLink = (
url: string,
Expand Down
32 changes: 31 additions & 1 deletion yarn.lock
Expand Up @@ -2840,6 +2840,20 @@ __metadata:
languageName: node
linkType: hard

"@verdaccio/core@npm:6.0.0-6-next.62":
version: 6.0.0-6-next.62
resolution: "@verdaccio/core@npm:6.0.0-6-next.62"
dependencies:
ajv: 8.11.2
core-js: 3.28.0
http-errors: 1.8.1
http-status-codes: 2.2.0
process-warning: 1.0.0
semver: 7.3.8
checksum: 628c35522e48b57aa01b9fa4ee869da7d3c8b9ac43905fe783a44d6e9f49b85a2298ee153b947c759cbc237ed9aba350fab2dd6698e74ebff6b9740a949d5718
languageName: node
linkType: hard

"@verdaccio/file-locking@npm:10.3.0":
version: 10.3.0
resolution: "@verdaccio/file-locking@npm:10.3.0"
Expand Down Expand Up @@ -4326,6 +4340,13 @@ __metadata:
languageName: node
linkType: hard

"core-js@npm:3.28.0":
version: 3.28.0
resolution: "core-js@npm:3.28.0"
checksum: 3155fd0ec16d0089106b145e9595280a4ea4bde0d7ff26aa14364cd4f1c203baf6620c3025acd284f363d08b9f21104101692766ca9a36ffeee7307bdf3e1881
languageName: node
linkType: hard

"core-js@npm:^2.6.5":
version: 2.6.12
resolution: "core-js@npm:2.6.12"
Expand Down Expand Up @@ -7631,6 +7652,13 @@ __metadata:
languageName: node
linkType: hard

"lru-cache@npm:7.17.0":
version: 7.17.0
resolution: "lru-cache@npm:7.17.0"
checksum: 28c2a98ad313b8d61beac1f08257b6f0ca990e39d24a9bc831030b6e209447cfb11c6d9d1a774282189bfc9609d1dfd17ebe485228dd68f7b96b6b9b7740894e
languageName: node
linkType: hard

"lru-cache@npm:^5.1.1":
version: 5.1.1
resolution: "lru-cache@npm:5.1.1"
Expand Down Expand Up @@ -10581,7 +10609,7 @@ __metadata:
"@typescript-eslint/parser": 5.49.0
"@verdaccio-scope/verdaccio-auth-foo": 0.0.2
"@verdaccio/config": 6.0.0-6-next.61
"@verdaccio/core": 6.0.0-6-next.61
"@verdaccio/core": 6.0.0-6-next.62
"@verdaccio/local-storage": 10.3.1
"@verdaccio/logger-7": 6.0.0-6-next.6
"@verdaccio/middleware": 6.0.0-6-next.40
Expand Down Expand Up @@ -10615,6 +10643,7 @@ __metadata:
eslint-plugin-simple-import-sort: 9.0.0
eslint-plugin-verdaccio: 10.0.0
express: 4.18.2
express-rate-limit: 5.5.1
fast-safe-stringify: 2.1.1
fs-extra: 10.1.0
get-port: 5.1.1
Expand All @@ -10630,6 +10659,7 @@ __metadata:
lint-staged: 11.0.1
lockfile-lint: 4.6.2
lodash: 4.17.21
lru-cache: 7.17.0
lunr-mutable-indexes: 2.3.2
mime: 3.0.0
mkdirp: 1.0.4
Expand Down