Skip to content

Commit

Permalink
Merge pull request #5 from DomNomNom/patch-2
Browse files Browse the repository at this point in the history
Added a serverUrl option.
  • Loading branch information
AlinaNova21 authored Jul 5, 2017
2 parents b477aec + 12bae8c commit 60acc96
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/screepsAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -228,4 +230,4 @@ function inflate (data) {
return JSON.parse(ret)
}

function noop () {}
function noop () {}

0 comments on commit 60acc96

Please sign in to comment.