Last active
September 18, 2020 19:12
-
-
Save theoomoregbee/c3c66a5b1b9d6a9241e4d1eb47983110 to your computer and use it in GitHub Desktop.
Get unique url query string params and how many times they showed up
This file contains 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 uniqueQueryParams = {}; | |
const occurenceCount = {} | |
const links = []; | |
for (let link of links) { | |
const url = new URL(links); | |
const params = new URLSearchParams(url.search); | |
processParams(params); | |
} | |
function processParams(params) { | |
for (const [key, value] of params.entries()) { | |
occurenceCount[key] = (occurenceCount[key] || 0) + 1; | |
if (!uniqueQueryParams[key]) { | |
uniqueQueryParams[key] = value; | |
} | |
} | |
} | |
console.log("unique query params", uniqueQueryParams, occurenceCount); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment