Created
September 13, 2020 07:57
-
-
Save onepointconsulting/0686e6dfbfc783d73fb619d6563c3d43 to your computer and use it in GitHub Desktop.
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
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); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
extractParameterSimple
is the function, that extracts the language from multiple sources. It has a fallbackdefaultValue
parameter in case the key is not found.