From 12bae8c365fd53f32bcec54d8e8b8559de90697e Mon Sep 17 00:00:00 2001 From: Dominik Schmid Date: Sat, 17 Jun 2017 20:37:24 +0200 Subject: [PATCH] Added a serverUrl option. Note: This is untested due to being edited on Github. --- src/screepsAPI.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/screepsAPI.js b/src/screepsAPI.js index 846760f..c7c326d 100644 --- a/src/screepsAPI.js +++ b/src/screepsAPI.js @@ -14,7 +14,9 @@ class ScreepsAPI extends EventEmitter { opts = opts || {} // if (!opts.email || !opts.password) throw new Error('Email and password REQUIRED') this.opts = opts - this.prefix = opts.ptr ? 'https://screeps.com/ptr' : 'https://screeps.com' + // TODO: validate serverUrl. (eg. starts with http(s):// ) + this.prefix = opts.serverUrl || 'https://screeps.com'; + if (opts.ptr) this.prefix += '/ptr'; } request (...args) { return new Promise((resolve, reject) => { @@ -228,4 +230,4 @@ function inflate (data) { return JSON.parse(ret) } -function noop () {} \ No newline at end of file +function noop () {}