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 git with a % character #72

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ function normalizeUrl(urlString, options) {
const parseUrl = (url, normalize = false) => {

// Constants
const GIT_RE = /^(?:([a-z_][a-z0-9_-]{0,31})@|https?:\/\/)([\w\.\-@]+)[\/:]([\~,\.\w,\-,\_,\/]+?(?:\.git|\/)?)$/;
const GIT_RE = /^(?:([a-z_][a-z0-9_-]{0,31})@|https?:\/\/)([\w\.\-@]+)[\/:]([\~,\.\w,\-,\_,\/,\%]+?(?:\.git|\/)?)$/;

const throwErr = msg => {
const err = new Error(msg);
Expand Down
2 changes: 1 addition & 1 deletion dist/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ function normalizeUrl(urlString, options) {
const parseUrl = (url, normalize = false) => {

// Constants
const GIT_RE = /^(?:([a-z_][a-z0-9_-]{0,31})@|https?:\/\/)([\w\.\-@]+)[\/:]([\~,\.\w,\-,\_,\/]+?(?:\.git|\/)?)$/;
const GIT_RE = /^(?:([a-z_][a-z0-9_-]{0,31})@|https?:\/\/)([\w\.\-@]+)[\/:]([\~,\.\w,\-,\_,\/,\%]+?(?:\.git|\/)?)$/;

const throwErr = msg => {
const err = new Error(msg);
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"description": "An advanced url parser supporting git urls too.",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./index.d.ts",
"exports": {
"types": {
"require": "./index.d.ts",
Expand Down Expand Up @@ -75,4 +74,4 @@
"tsd": {
"directory": "test"
}
}
}
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import normalizeUrl from "normalize-url";
const parseUrl = (url, normalize = false) => {

// Constants
const GIT_RE = /^(?:([a-z_][a-z0-9_-]{0,31})@|https?:\/\/)([\w\.\-@]+)[\/:]([\~,\.\w,\-,\_,\/]+?(?:\.git|\/)?)$/
const GIT_RE = /^(?:([a-z_][a-z0-9_-]{0,31})@|https?:\/\/)([\w\.\-@]+)[\/:]([\~,\.\w,\-,\_,\/,\%]+?(?:\.git|\/)?)$/

const throwErr = msg => {
const err = new Error(msg)
Expand Down
15 changes: 15 additions & 0 deletions test/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,21 @@ const INPUTS = [
, query: {}
, parse_failed: false
}
], [
["git@ssh.dev.azure.com:v3/compagny/Project%20Space/Project-nonSpace", false]
, {
protocols: [ "ssh" ]
, protocol: "ssh"
, port: ""
, resource: "ssh.dev.azure.com"
, host: "ssh.dev.azure.com"
, user: "git"
, pathname: "/v3/compagny/Project%20Space/Project-nonSpace"
, hash: ""
, search: ""
, query: {}
, parse_failed: false
}
]
];

Expand Down