2018-01-19 05:52:58 +00:00
|
|
|
const isLocalhost = process.browser && process.env.NODE_ENV !== 'production' &&
|
|
|
|
(document.location.hostname === 'localhost' ||
|
|
|
|
document.location.hostname === '127.0.0.1')
|
|
|
|
|
2018-02-09 06:29:29 +00:00
|
|
|
function targetIsLocalhost (instanceName) {
|
2018-01-19 05:52:58 +00:00
|
|
|
return process.browser && process.env.NODE_ENV !== 'production' &&
|
|
|
|
(instanceName === 'localhost:3000' || instanceName === '127.0.0.1:3000')
|
|
|
|
}
|
|
|
|
|
2018-02-09 06:29:29 +00:00
|
|
|
export function basename (instanceName) {
|
2018-01-19 05:52:58 +00:00
|
|
|
if (isLocalhost && targetIsLocalhost(instanceName)) {
|
|
|
|
return `http://${instanceName}`
|
|
|
|
}
|
|
|
|
return `https://${instanceName}`
|
2018-02-09 06:29:29 +00:00
|
|
|
}
|