about summary refs log tree commit diff stats
path: root/src/types/url.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-10-28 00:07:02 +0100
committerbptato <nincsnevem662@gmail.com>2024-10-28 00:09:26 +0100
commit64504d633d55074f902eda041b7c720d305d5338 (patch)
tree9e1629319b9db061598d17969d9e6af929e08747 /src/types/url.nim
parent314c91d62441415d175aa366764754eb64efa4f7 (diff)
downloadchawan-64504d633d55074f902eda041b7c720d305d5338.tar.gz
url: add searchParams.has
Diffstat (limited to 'src/types/url.nim')
-rw-r--r--src/types/url.nim8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/types/url.nim b/src/types/url.nim
index 756bf344..7647d3a1 100644
--- a/src/types/url.nim
+++ b/src/types/url.nim
@@ -1191,6 +1191,14 @@ proc getAll(params: URLSearchParams; name: string): seq[string] {.jsfunc.} =
     if it[0] == name:
       result.add(it[1])
 
+proc has(params: URLSearchParams; name: string; value = none(string)): bool
+    {.jsfunc.} =
+  for it in params.list:
+    if it.name == name:
+      if value.isNone or value.get == it.value:
+        return true
+  return false
+
 proc set(params: URLSearchParams; name, value: string) {.jsfunc.} =
   var first = true
   for i in 0..params.list.high: