|
|
@ -99,8 +99,6 @@ class TupleOrigin { |
|
|
|
|
|
|
|
function onParseComplete(flags, protocol, username, password, |
|
|
|
host, port, path, query, fragment) { |
|
|
|
if (flags & binding.URL_FLAGS_FAILED) |
|
|
|
throw new TypeError('Invalid URL'); |
|
|
|
var ctx = this[context]; |
|
|
|
ctx.flags = flags; |
|
|
|
ctx.scheme = protocol; |
|
|
@ -118,19 +116,23 @@ function onParseComplete(flags, protocol, username, password, |
|
|
|
initSearchParams(this[searchParams], query); |
|
|
|
} |
|
|
|
|
|
|
|
function onParseError(flags, input) { |
|
|
|
const error = new TypeError('Invalid URL: ' + input); |
|
|
|
error.input = input; |
|
|
|
throw error; |
|
|
|
} |
|
|
|
|
|
|
|
// Reused by URL constructor and URL#href setter.
|
|
|
|
function parse(url, input, base) { |
|
|
|
const base_context = base ? base[context] : undefined; |
|
|
|
url[context] = new StorageObject(); |
|
|
|
binding.parse(input.trim(), -1, |
|
|
|
base_context, undefined, |
|
|
|
onParseComplete.bind(url)); |
|
|
|
onParseComplete.bind(url), onParseError); |
|
|
|
} |
|
|
|
|
|
|
|
function onParseProtocolComplete(flags, protocol, username, password, |
|
|
|
host, port, path, query, fragment) { |
|
|
|
if (flags & binding.URL_FLAGS_FAILED) |
|
|
|
return; |
|
|
|
const newIsSpecial = (flags & binding.URL_FLAGS_SPECIAL) !== 0; |
|
|
|
const s = this[special]; |
|
|
|
const ctx = this[context]; |
|
|
@ -159,8 +161,6 @@ function onParseProtocolComplete(flags, protocol, username, password, |
|
|
|
|
|
|
|
function onParseHostComplete(flags, protocol, username, password, |
|
|
|
host, port, path, query, fragment) { |
|
|
|
if (flags & binding.URL_FLAGS_FAILED) |
|
|
|
return; |
|
|
|
const ctx = this[context]; |
|
|
|
if (host) { |
|
|
|
ctx.host = host; |
|
|
@ -174,8 +174,6 @@ function onParseHostComplete(flags, protocol, username, password, |
|
|
|
|
|
|
|
function onParseHostnameComplete(flags, protocol, username, password, |
|
|
|
host, port, path, query, fragment) { |
|
|
|
if (flags & binding.URL_FLAGS_FAILED) |
|
|
|
return; |
|
|
|
const ctx = this[context]; |
|
|
|
if (host) { |
|
|
|
ctx.host = host; |
|
|
@ -187,15 +185,11 @@ function onParseHostnameComplete(flags, protocol, username, password, |
|
|
|
|
|
|
|
function onParsePortComplete(flags, protocol, username, password, |
|
|
|
host, port, path, query, fragment) { |
|
|
|
if (flags & binding.URL_FLAGS_FAILED) |
|
|
|
return; |
|
|
|
this[context].port = port; |
|
|
|
} |
|
|
|
|
|
|
|
function onParsePathComplete(flags, protocol, username, password, |
|
|
|
host, port, path, query, fragment) { |
|
|
|
if (flags & binding.URL_FLAGS_FAILED) |
|
|
|
return; |
|
|
|
const ctx = this[context]; |
|
|
|
if (path) { |
|
|
|
ctx.path = path; |
|
|
@ -207,16 +201,12 @@ function onParsePathComplete(flags, protocol, username, password, |
|
|
|
|
|
|
|
function onParseSearchComplete(flags, protocol, username, password, |
|
|
|
host, port, path, query, fragment) { |
|
|
|
if (flags & binding.URL_FLAGS_FAILED) |
|
|
|
return; |
|
|
|
const ctx = this[context]; |
|
|
|
ctx.query = query; |
|
|
|
} |
|
|
|
|
|
|
|
function onParseHashComplete(flags, protocol, username, password, |
|
|
|
host, port, path, query, fragment) { |
|
|
|
if (flags & binding.URL_FLAGS_FAILED) |
|
|
|
return; |
|
|
|
const ctx = this[context]; |
|
|
|
if (fragment) { |
|
|
|
ctx.fragment = fragment; |
|
|
|