Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
build(path: string = '/'): string {
if (!this.fastboot.isFastBoot) {
return `${window.location.protocol}//${window.location.host}${path}`;
}
const request = this.fastboot.request;
// NOTE: On Heroku, `request.get('protocol')` returns `"http:"`
// even if it’s an HTTPS request, so we can’t use it.
const protocol = config.APP.FORCE_SSL ? 'https:' : 'http:';
return `${protocol}//${request.host}${path}`;
}
}
beforeModel(transition) {
let newDynObject = {};
let thisRouteName = this.routeName;
let routeNames = this.router._routerMicrolib.recognizer.names;
let dynSegsOfNextRoute = null;
let dynSegsOfThisRoute = null;
// If the redirect route is not a valid route name in this app AND then redirect
// looks like a url, send um that-a-way via location.replace
if (!routeNames[options.redirect] && resemblesURL(options.redirect)) {
transition.abort();
window.location.assign(options.redirect);
return false;
}
dynSegsOfNextRoute = getDynamicSegments(routeNames[options.redirect].segments);
dynSegsOfThisRoute = getDynamicSegments(routeNames[thisRouteName].segments);
// Make sure we only try to make a redirect at the most nested
// route and not a parent resource.
if(this.routeName !== transition.targetName) {
return false;
}
// Make sure that the lengths are the same else we are trying to transition to a route that needs more
// segments then we can supply.
if(dynSegsOfNextRoute.length <= dynSegsOfThisRoute.length) {
let end;
// if we're targeting a container, account for offset to start and end
if (options.container) {
end = {
y: element.offsetTop,
x: element.offsetLeft
};
let container = this.getContainer(options.container);
start.y = container.scrollTop;
end.y = end.y - container.offsetTop;
start.x = container.scrollLeft;
end.x = end.x - container.offsetLeft;
} else {
end = {
y: window.pageYOffset + element.getBoundingClientRect().top,
x: window.pageXOffset + element.getBoundingClientRect().left
};
}
yield this.get('scrollToTask').perform(start, end, options);
}),
};
let end;
// if we're targeting a container, account for offset to start and end
if (options.container) {
end = {
y: element.offsetTop,
x: element.offsetLeft
};
let container = this.getContainer(options.container);
start.y = container.scrollTop;
end.y = end.y - container.offsetTop;
start.x = container.scrollLeft;
end.x = end.x - container.offsetLeft;
} else {
end = {
y: window.pageYOffset + element.getBoundingClientRect().top,
x: window.pageXOffset + element.getBoundingClientRect().left
};
}
yield this.get('scrollToTask').perform(start, end, options);
}),
init() {
this._super(...arguments);
this.set('counter', +window.localStorage.getItem('counter') || 1);
},
redirect(url) {
window.location.href = url;
},
increment() {
this.incrementProperty('counter');
window.localStorage.setItem('counter', this.get('counter'));
}
}
export default function getHardwareConcurrency() {
let initialHardwareConcurrency;
if (typeof window.navigator !== 'undefined' && 'hardwareConcurrency' in window.navigator) {
initialHardwareConcurrency = { numberOfLogicalProcessors: window.navigator.hardwareConcurrency };
} else {
initialHardwareConcurrency = { unsupported: true };
}
return initialHardwareConcurrency;
}
export default function getMemoryStatus() {
let unsupported;
if (typeof window.navigator !== 'undefined' && 'deviceMemory' in window.navigator) {
unsupported = false;
} else {
unsupported = true;
}
let initialMemoryStatus;
if (!unsupported) {
const performanceMemory = 'memory' in window.performance ? window.performance.memory : null;
initialMemoryStatus = {
deviceMemory: window.navigator.deviceMemory,
totalJSHeapSize: performanceMemory ? performanceMemory.totalJSHeapSize : null,
usedJSHeapSize: performanceMemory ? performanceMemory.usedJSHeapSize : null,
jsHeapSizeLimit: performanceMemory ? performanceMemory.jsHeapSizeLimit : null
};
} else {
initialMemoryStatus = { unsupported };
}
export default function getNetworkStatus() {
if ('connection' in window.navigator && 'effectiveType' in window.navigator.connection) {
unsupported = false;
} else {
unsupported = true;
}
return !unsupported ? {
effectiveConnectionType: window.navigator.connection.effectiveType
} : {
unsupported
};
}