Skip to content

Instantly share code, notes, and snippets.

@schalkneethling
Created May 15, 2019 16:27
Show Gist options
  • Save schalkneethling/08e8596b5956984335ac703de79290c2 to your computer and use it in GitHub Desktop.
Save schalkneethling/08e8596b5956984335ac703de79290c2 to your computer and use it in GitHub Desktop.
Allow posts from beta domain
function setupConfig() {
// assume production as origin
var origin = "https://developer.mozilla.org";
// get the actual parent origin
var parentOrigin = window.parent.location.origin;
// is it the beta domain?
if (parentOrigin.search(/beta.developer.(mozilla|allizom)/) > -1) {
// then use it as the origin
origin = parentOrigin;
} else if (window.URL) {
// look for the search param
var url = new URL(window.location.href);
if (url.searchParams) {
var param = url.searchParams.get("origin");
if (param) {
// and use it as the origin
origin = param;
}
}
}
// finally set the config
window.ieConfig = {
origin: origin
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment