about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-05-22 16:59:27 +0200
committerbptato <nincsnevem662@gmail.com>2024-05-22 16:59:27 +0200
commit8c7a2a582baff30ccbf76f52b6b48cc979ea62e2 (patch)
tree86eb099f252d476eeb2456979232440255ea9885
parent2822dbed8b2011aa02cf43fc2f40d25e4950911f (diff)
downloadchawan-8c7a2a582baff30ccbf76f52b6b48cc979ea62e2.tar.gz
url: add URL.parse
Pointless bloat that fixes no real problems, but it's standard now...

(Are we supposed to add a helper function that returns null for *every*
constructor that can throw now?)
-rw-r--r--src/types/url.nim3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/types/url.nim b/src/types/url.nim
index 585bb64b..c82555de 100644
--- a/src/types/url.nim
+++ b/src/types/url.nim
@@ -1226,6 +1226,9 @@ proc setHash*(url: URL; s: string) {.jsfset: "hash".} =
   url.fragment = some("")
   discard basicParseURL(s, url = url, stateOverride = some(usFragment))
 
+proc jsParse(url: string; base = none(string)): URL {.jsstfunc: "URL:parse".} =
+  return parseAPIURL(url, base).get(nil)
+
 proc canParse(url: string; base = none(string)): bool {.jsstfunc: "URL".} =
   return parseAPIURL(url, base).isSome