How to accept only few keys as query paramter with any value #298
-
If someone can please help in a pattern that accepts only specified query parameters with any value. Eg: Only query a and b is allowed https://host/path?a=apple&b=banana ---- PASS |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
You want to allow only the query parameters "a" and "b" in the URL, while ignoring any other parameters. You can achieve it like this in JS: const allowedParams = ["a", "b"]; function validateURL(url) { console.log(validateURL("https://host/path?a=apple&b=banana")); // PASS |
Beta Was this translation helpful? Give feedback.
Hi @sohaibaumer
Thanks for the answer but I was thinking of a solution using this (path-to-regexp) library itself