Skip to content

Instantly share code, notes, and snippets.

@onepointconsulting
Created September 13, 2020 07:57
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 onepointconsulting/0686e6dfbfc783d73fb619d6563c3d43 to your computer and use it in GitHub Desktop.
Save onepointconsulting/0686e6dfbfc783d73fb619d6563c3d43 to your computer and use it in GitHub Desktop.
export const extractParameterSimple = (name, defaultValue) => extractParameter(null, name, defaultValue);
export const extractParameter = (props, name, defaultValue) => {
return (props && props.match.params[name]) || extractFromLocationQuery(name) || window.eventsConfig[name]
|| defaultValue;
};
export const extractFromLocationQuery = (param) => {
const url = new URL(window.location.href);
return url.searchParams.get(param);
};
@onepointconsulting
Copy link
Author

extractParameterSimple is the function, that extracts the language from multiple sources. It has a fallback defaultValue parameter in case the key is not found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment