Skip to content

Commit

Permalink
options.url cleanup for services
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickarlt committed Jan 6, 2015
1 parent d95f965 commit 582d373
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/Services/Service.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ EsriLeaflet.Services.Service = L.Class.extend({
},

initialize: function (options) {
this.url = EsriLeaflet.Util.cleanUrl(options.url);
options = options || {};
this._requestQueue = [];
this._authenticating = false;
L.Util.setOptions(this, options);
this.options.url = EsriLeaflet.Util.cleanUrl(this.options.url);
},

get: function (path, params, callback, context) {
Expand Down Expand Up @@ -39,7 +40,7 @@ EsriLeaflet.Services.Service = L.Class.extend({

_request: function(method, path, params, callback, context){
this.fire('requeststart', {
url: this.url + path,
url: this.options.url + path,
params: params,
method: method
});
Expand All @@ -54,7 +55,7 @@ EsriLeaflet.Services.Service = L.Class.extend({
this._requestQueue.push([method, path, params, callback, context]);
return;
} else {
var url = (this.options.proxy) ? this.options.proxy + '?' + this.url + path : this.url + path;
var url = (this.options.proxy) ? this.options.proxy + '?' + this.options.url + path : this.options.url + path;

if((method === 'get' || method === 'request') && !this.options.useCors){
return EsriLeaflet.Request.get.JSONP(url, params, wrappedCallback);
Expand Down Expand Up @@ -82,23 +83,23 @@ EsriLeaflet.Services.Service = L.Class.extend({

if(error) {
this.fire('requesterror', {
url: this.url + path,
url: this.options.url + path,
params: params,
message: error.message,
code: error.code,
method: method
});
} else {
this.fire('requestsuccess', {
url: this.url + path,
url: this.options.url + path,
params: params,
response: response,
method: method
});
}

this.fire('requestend', {
url: this.url + path,
url: this.options.url + path,
params: params,
method: method
});
Expand Down

0 comments on commit 582d373

Please sign in to comment.