Skip to content

Commit

Permalink
add more test proxy (verdaccio#2236)
Browse files Browse the repository at this point in the history
* add more test proxy

* test tarball and search

* format

* refactor uplinks
  • Loading branch information
juanpicado authored May 8, 2021
1 parent 8582548 commit 52b4786
Show file tree
Hide file tree
Showing 15 changed files with 1,597 additions and 5,304 deletions.
4 changes: 2 additions & 2 deletions packages/core/tarball/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
},
"devDependencies": {
"@verdaccio/types": "workspace:11.0.0-6-next.7",
"express": "^4.17.1",
"node-mocks-http": "^1.10.1"
"express": "4.17.1",
"node-mocks-http": "1.10.1"
},
"scripts": {
"clean": "rimraf ./build",
Expand Down
5 changes: 3 additions & 2 deletions packages/proxy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@
"@verdaccio/streams": "workspace:11.0.0-alpha.3",
"@verdaccio/utils": "workspace:6.0.0-6-next.4",
"JSONStream": "1.3.5",
"lodash": "^4.17.20",
"lodash": "4.17.20",
"request": "2.87.0"
},
"devDependencies": {
"@verdaccio/types": "workspace:11.0.0-6-next.7",
"nock": "13.0.11"
"nock": "13.0.11",
"node-mocks-http": "1.10.1"
},
"funding": {
"type": "opencollective",
Expand Down
1 change: 0 additions & 1 deletion packages/proxy/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './up-storage';
export * from './uplink-util';
22 changes: 0 additions & 22 deletions packages/proxy/src/up-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ export interface IProxy {
fail_timeout: number;
upname: string;
fetchTarball(url: string): IReadTarball;
isUplinkValid(url: string): boolean;
search(options: any);
getRemoteMetadata(name: string, options: any, callback: Callback): void;
}
Expand Down Expand Up @@ -436,27 +435,6 @@ class ProxyStorage implements IProxy {
}
}

/**
* Determine whether can fetch from the provided URL
* @param {*} url
* @return {Boolean}
*/
public isUplinkValid(url: string): boolean {
// $FlowFixMe
const urlParsed: UrlWithStringQuery = URL.parse(url);
const isHTTPS = (urlDomainParsed: URL): boolean =>
urlDomainParsed.protocol === 'https:' &&
(urlParsed.port === null || urlParsed.port === '443');
const getHost = (urlDomainParsed): boolean =>
isHTTPS(urlDomainParsed) ? urlDomainParsed.hostname : urlDomainParsed.host;
const isMatchProtocol: boolean = urlParsed.protocol === this.url.protocol;
const isMatchHost: boolean = getHost(urlParsed) === getHost(this.url);
// @ts-ignore
const isMatchPath: boolean = urlParsed.path.indexOf(this.url.path) === 0;

return isMatchProtocol && isMatchHost && isMatchPath;
}

/**
* Get a remote package metadata
* @param {*} name package name
Expand Down
Binary file added packages/proxy/test/partials/jquery-0.0.1.tgz
Binary file not shown.
Loading

0 comments on commit 52b4786

Please sign in to comment.