pinafore/src/routes/_api/utils.js

17 lines
393 B
JavaScript
Raw Normal View History

2018-02-08 22:29:29 -08:00
function targetIsLocalhost (instanceName) {
2018-02-24 21:27:32 -08:00
return instanceName.startsWith('localhost:') || instanceName.startsWith('127.0.0.1:')
}
2018-02-08 22:29:29 -08:00
export function basename (instanceName) {
if (targetIsLocalhost(instanceName)) {
return `http://${instanceName}`
}
return `https://${instanceName}`
2018-02-08 22:29:29 -08:00
}
2018-02-24 14:49:28 -08:00
export function auth (accessToken) {
return {
2019-08-03 13:49:37 -07:00
Authorization: `Bearer ${accessToken}`
2018-02-24 14:49:28 -08:00
}
}