mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
0.2.5 initial commit
Makefile incomplete
This commit is contained in:
33
ui/src/app/services/config.service.ts
Normal file
33
ui/src/app/services/config.service.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { Injectable } from '@angular/core'
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ConfigService {
|
||||
origin = removePort(removeProtocol(window.origin))
|
||||
version = require('../../../package.json').version
|
||||
|
||||
api = {
|
||||
useMocks: require('../../../use-mocks.json').useMocks,
|
||||
url: '/api',
|
||||
version: '/v0',
|
||||
root: '', // empty will default to same origin
|
||||
}
|
||||
|
||||
isConsulateIos = window['platform'] === 'ios'
|
||||
isConsulateAndroid = window['platform'] === 'android'
|
||||
|
||||
isTor () : boolean {
|
||||
return this.api.useMocks || this.origin.endsWith('.onion')
|
||||
}
|
||||
}
|
||||
|
||||
function removeProtocol (str: string): string {
|
||||
if (str.startsWith('http://')) return str.slice(7)
|
||||
if (str.startsWith('https://')) return str.slice(8)
|
||||
return str
|
||||
}
|
||||
|
||||
function removePort (str: string): string {
|
||||
return str.split(':')[0]
|
||||
}
|
||||
Reference in New Issue
Block a user