qb-admin-fe/src/api/utils.js

11 lines
354 B
JavaScript
Raw Normal View History

2019-03-23 14:09:48 +00:00
const isLocalhost = (instanceName) =>
instanceName.startsWith('localhost:') || instanceName.startsWith('127.0.0.1:')
export const baseName = (instanceName = 'localhost') => {
if (instanceName.match(/https?:\/\//)) {
return instanceName
} else {
return isLocalhost(instanceName) ? `http://${instanceName}` : `https://${instanceName}`
}
}