Skip to content

Commit

Permalink
[Fix] avoid node 22 url.parse deprecation warning
Browse files Browse the repository at this point in the history
Fixes #30. Fixes #15.
  • Loading branch information
ljharb committed Jun 25, 2024
1 parent 4d46f90 commit 37881a3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function parse(str) {

if (!obj.host && (/^git@/).test(str) === true) {
// return the correct host for git@ URLs
obj.host = url.parse('http://' + str).host;
obj.host = url.parse('http://' + str.replace(/git@([^:]+):/, '$1/')).host;
}

obj.path = trimSlash(obj.path);
Expand Down
4 changes: 4 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ var test = require('tape');
var gh = require('../');

test('parse-github-url', function (t) {
process.on('warning', function (e) {
t.fail(e, 'no deprecation warnings are issued');
});

t.equal(gh('toString').href, 'toString');

t.test('gets the user:', function (assert) {
Expand Down

0 comments on commit 37881a3

Please sign in to comment.