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

Added relative protocol to the table #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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