pinafore/routes/_api/utils.js
Nolan Lawson d93811d470 refactor
2018-02-08 08:22:14 -08:00

15 lines
541 B
JavaScript

const isLocalhost = process.browser && process.env.NODE_ENV !== 'production' &&
(document.location.hostname === 'localhost' ||
document.location.hostname === '127.0.0.1')
function targetIsLocalhost(instanceName) {
return process.browser && process.env.NODE_ENV !== 'production' &&
(instanceName === 'localhost:3000' || instanceName === '127.0.0.1:3000')
}
export function basename(instanceName) {
if (isLocalhost && targetIsLocalhost(instanceName)) {
return `http://${instanceName}`
}
return `https://${instanceName}`
}