| 69 | } |
| 70 | |
| 71 | function getSchnackDomain() { |
| 72 | const schnack_host = config.get('schnack_host'); |
| 73 | try { |
| 74 | const schnack_url = new URL(schnack_host); |
| 75 | |
| 76 | if (schnack_url.hostname === 'localhost') { |
| 77 | return schnack_url.hostname; |
| 78 | } else { |
| 79 | const schnack_domain = schnack_url.hostname |
| 80 | .split('.') |
| 81 | .slice(1) |
| 82 | .join('.'); |
| 83 | return schnack_domain; |
| 84 | } |
| 85 | } catch (error) { |
| 86 | console.error( |
| 87 | `The schnack_host value "${schnack_host}" doesn't appear to be a proper URL. Did you forget "http://"?` |
| 88 | ); |
| 89 | process.exit(-1); |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | module.exports = { |
| 94 | send_file, |