Make baseName check if http is already in the name

This commit is contained in:
Ekaterina Vaartis 2019-09-24 20:10:50 +03:00
parent 10d3f3f0a0
commit 2662210063

View file

@ -1,5 +1,10 @@
const isLocalhost = (instanceName) =>
instanceName.startsWith('localhost:') || instanceName.startsWith('127.0.0.1:')
export const baseName = (instanceName) =>
isLocalhost(instanceName) ? `http://${instanceName}` : `https://${instanceName}`
export const baseName = (instanceName) => {
if (instanceName.match(/https?:\/\//)) {
return instanceName
} else {
return isLocalhost(instanceName) ? `http://${instanceName}` : `https://${instanceName}`
}
}