Skip to content

Instantly share code, notes, and snippets.

@odbol
Created October 3, 2022 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save odbol/034ef3024a0ee5fae5474db6e5df3a2d to your computer and use it in GitHub Desktop.
Save odbol/034ef3024a0ee5fae5474db6e5df3a2d to your computer and use it in GitHub Desktop.
Utility functions for parsing querystrings and other useful JS goodies
/** 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