Skip to content
Open
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
15 changes: 10 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,16 @@
query = splitted[4];
fragment = splitted[5];

// scheme and path are required, though the path can be empty
if (!(scheme && scheme.length && path.length >= 0)) return;
if (!scheme && /^\/\//.test(value)) {
scheme = "";
} else {

// scheme and path are required, though the path can be empty
if (!(scheme && scheme.length && path.length >= 0)) return;

// scheme must begin with a letter, then consist of letters, digits, +, ., or -
if (!/^[a-z][a-z0-9\+\-\.]*$/.test(scheme.toLowerCase())) return;
}

// if authority is present, the path must be empty or begin with a /
if (authority && authority.length) {
Expand All @@ -58,9 +66,6 @@
if (/^\/\//.test(path)) return;
}

// scheme must begin with a letter, then consist of letters, digits, +, ., or -
if (!/^[a-z][a-z0-9\+\-\.]*$/.test(scheme.toLowerCase())) return;

// re-assemble the URL per section 5.3 in RFC 3986
out += scheme + ':';
if (authority && authority.length) {
Expand Down
Loading