Created
October 3, 2022 22:45
-
-
Save odbol/034ef3024a0ee5fae5474db6e5df3a2d to your computer and use it in GitHub Desktop.
Utility functions for parsing querystrings and other useful JS goodies
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
/** Returns the first querystring parameter with the given key, or null if not found. */ | |
export function getParam(param: string): string|null { | |
var dataCallbackMatches = new RegExp(param + '=([^&]+)').exec(document.location.href); | |
if (dataCallbackMatches) { | |
return dataCallbackMatches[1]; | |
} else { | |
return null; | |
} | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment