forked from yarnpkg/yarn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix private urls using colon separator (yarnpkg#2519)
* Fix private urls using colon separator Closes yarnpkg#573, closes yarnpkg#2416. Related to yarnpkg#2384, yarnpkg#573. * Remove unused suppression * Move to dedicated method & add tests
- Loading branch information
Showing
2 changed files
with
62 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* @flow */ | ||
|
||
import {parse} from 'url'; | ||
|
||
import GitResolver from '../../../src/resolvers/exotics/git-resolver.js'; | ||
|
||
test('GitResolver transformUrl method is defined', () => { | ||
expect(GitResolver.transformUrl).toBeDefined(); | ||
}); | ||
|
||
test('GitResolver transformUrl does not affect normal urls', () => { | ||
|
||
const urls = [ | ||
'git+https://github.com/npm-ml/ocaml.git#npm-4.02.3', | ||
'git+ssh://[email protected]/user/repo.git', | ||
'git+ssh://[email protected]/user/repo.git', | ||
'git+ssh://[email protected]/sub/right-pad', | ||
'https://github.com/npm-ml/re', | ||
'https://github.com/npm-ml/ocaml.git#npm-4.02.3', | ||
'https://[email protected]/stevemao/left-pad.git', | ||
'https://bitbucket.org/hgarcia/node-bitbucket-api.git', | ||
'https://github.com/yarnpkg/yarn/releases/download/v0.18.1/yarn-v0.18.1.tar.gz', | ||
'https://github.com/babel/babel-loader.git#greenkeeper/cross-env-3.1.4', | ||
'package@[email protected]:team/repo.git', | ||
]; | ||
|
||
urls.forEach((url) => { | ||
expect(GitResolver.transformUrl(parse(url))).toBe(url); | ||
}); | ||
|
||
}); | ||
|
||
test('GitResolver transformUrl affect host colon separated urls', () => { | ||
|
||
const urls = [ | ||
'git+ssh://[email protected]:sub/right-pad', | ||
'git+ssh://private.url:sub/right-pad', | ||
'https://private.url:sub/right-pad', | ||
]; | ||
|
||
urls.forEach((url) => { | ||
expect(GitResolver.transformUrl(parse(url))).toBe(url.replace(':sub', '/sub')); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters