about summary refs log tree commit diff
path: root/lib/tests
diff options
context:
space:
mode:
authorPatrick Widmer <patrick.widmer@tbwnet.ch>2023-03-02 21:41:51 +0100
committerPatrick Widmer <patrick.widmer@tbwnet.ch>2023-03-03 20:48:55 +0100
commit7089294f10068dbeeed6e2e4d7a24300bf4bacb6 (patch)
treeb905d320eb3a640282fff4d98b0e9068fb136fe0 /lib/tests
parent55fc05fb8ccce47595ce9607ed2b2e4d49538c0a (diff)
strings: add escapeQuery for url encoding
Diffstat (limited to 'lib/tests')
-rw-r--r--lib/tests/misc.nix9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix
index 406656dac1a92..07d04f5356c7b 100644
--- a/lib/tests/misc.nix
+++ b/lib/tests/misc.nix
@@ -347,6 +347,15 @@ runTests {
     expected = "Hello\\x20World";
   };
 
+  testEscapeURL = testAllTrue [
+    ("" == strings.escapeURL "")
+    ("Hello" == strings.escapeURL "Hello")
+    ("Hello%20World" == strings.escapeURL "Hello World")
+    ("Hello%2FWorld" == strings.escapeURL "Hello/World")
+    ("42%25" == strings.escapeURL "42%")
+    ("%20%3F%26%3D%23%2B%25%21%3C%3E%23%22%7B%7D%7C%5C%5E%5B%5D%60%09%3A%2F%40%24%27%28%29%2A%2C%3B" == strings.escapeURL " ?&=#+%!<>#\"{}|\\^[]`\t:/@$'()*,;")
+  ];
+
   testToInt = testAllTrue [
     # Naive
     (123 == toInt "123")