1 | 'use strict'
|
2 |
|
3 | const url = require('url')
|
4 |
|
5 | class Vars {
|
6 | constructor (env) {
|
7 | this.env = env
|
8 | }
|
9 |
|
10 | get host () { return this.env.HEROKU_HOST || 'heroku.com' }
|
11 | get apiUrl () { return this.host.startsWith('http') ? this.host : `https://api.${this.host}` }
|
12 | get apiHost () {
|
13 | if (this.host.startsWith('http')) {
|
14 | const u = url.parse(this.host)
|
15 | if (u.host) return u.host
|
16 | }
|
17 | return `api.${this.host}`
|
18 | }
|
19 | get httpGitHost () {
|
20 | if (this.env.HEROKU_GIT_HOST) return this.env.HEROKU_GIT_HOST
|
21 | if (this.host.startsWith('http')) {
|
22 | const u = url.parse(this.host)
|
23 | if (u.host) return u.host
|
24 | }
|
25 | return `git.${this.host}`
|
26 | }
|
27 | }
|
28 |
|
29 | module.exports = new Vars(process.env)
|