about summary refs log tree commit diff stats
path: root/src/types
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-12-05 09:01:29 +0100
committerbptato <nincsnevem662@gmail.com>2022-12-05 09:01:29 +0100
commit4137297efe003cec8e4d9eed810d1f801a21dfce (patch)
tree335b9702e40145d91c19820bdd391a8387731613 /src/types
parent645b3bc675f4fca925538c4beee1408d01692810 (diff)
downloadchawan-4137297efe003cec8e4d9eed810d1f801a21dfce.tar.gz
Proper fix for url hash setter
Diffstat (limited to 'src/types')
-rw-r--r--src/types/url.nim3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/types/url.nim b/src/types/url.nim
index f77faec1..1476a566 100644
--- a/src/types/url.nim
+++ b/src/types/url.nim
@@ -702,7 +702,6 @@ proc basicParseUrl*(input: string, base = none(Url), url: Url = Url(), stateOver
       #TODO encoding
       if not has or (not override and c == '#'):
         let querypercentencodeset = if url.is_special: SpecialQueryPercentEncodeSet else: QueryPercentEncodeSet
-        if url.query.isNone: url.query = some("")
         url.query.get.percentEncode(buffer, querypercentencodeset)
         buffer = ""
         if has and c == '#':
@@ -716,7 +715,6 @@ proc basicParseUrl*(input: string, base = none(Url), url: Url = Url(), stateOver
       if has:
         #TODO If c is not a URL code point and not U+0025 (%), validation error.
         #TODO If c is U+0025 (%) and remaining does not start with two ASCII hex digits, validation error.
-        if url.fragment.isNone: url.fragment = some("")
         url.fragment.get.percentEncode(c, FragmentPercentEncodeSet)
     inc pointer
   return url.some
@@ -1074,6 +1072,7 @@ proc hash*(url: URL, s: string) {.jsfset.} =
     url.fragment = none(string)
     return
   let s = if s[0] == '#': s.substr(1) else: s
+  url.fragment = some("")
   discard basicParseUrl(s, url = url, stateOverride = some(FRAGMENT_STATE))
 
 proc addUrlModule*(ctx: JSContext) =