Skip to content

Commit

Permalink
Add support for github: in package.json (OctoLinker#794)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanbuck authored Jan 26, 2020
1 parent 0299944 commit 49be306
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
4 changes: 3 additions & 1 deletion e2e/fixtures/javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"//": "@OctoLinkerResolve(https://github.com/mochajs/mocha/tree/v7.0.0)",
"mocha": "mochajs/mocha#v7.0.0",
"//": "@OctoLinkerResolve(https://github.com/angular/angular)",
"angular": "[email protected]:angular/angular.git"
"angular": "[email protected]:angular/angular.git",
"//": "@OctoLinkerResolve(https://github.com/pinkipi/log)",
"log": "github:pinkipi/log"
}
}
2 changes: 1 addition & 1 deletion packages/plugin-npm-manifest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default {
return [
githubShorthand({ target: values[1] }),
gitUrl({ target: values[1] }),
].map(url => resolverTrustedUrl({ target: url }));
].map(url => url && resolverTrustedUrl({ target: url }));
},

getPattern() {
Expand Down
10 changes: 10 additions & 0 deletions packages/resolver-github-shorthand/__tests__/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import resolver from '../index';

describe('resolver-github-shorthand', () => {
test.each([['https://github.com/foo/bar'], ['github:foo/bar']])(
'resolves "%s" to https://github.com/foo/bar',
target => {
expect(resolver({ target })).toEqual('https://github.com/foo/bar');
},
);
});
1 change: 1 addition & 0 deletions packages/resolver-github-shorthand/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ghShorthand from 'github-url-from-username-repo';

export default function({ target }) {
target = target.replace(/^github\:/, '');
return ghShorthand(target.replace(/^https:\/\/github.com\//, ''), true);
}

0 comments on commit 49be306

Please sign in to comment.