Last active
April 5, 2019 19:12
-
-
Save cvan/414a0c1cc8df3a48aed2767729c51f38 to your computer and use it in GitHub Desktop.
get truthy value from key from `URLSearchParams`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const qs = new URLSearchParams(window.location.search); | |
function getTruthyQS (key) { | |
if (!qs || !qs.has(key)) { | |
return false; | |
} | |
const valueLower = (qs.get('key') || '').trim().toLowerCase(); | |
return valueLower === '' || valueLower === '1' || valueLower === 'true' || valueLower === 'yes' || valueLower === 'on'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment