Skip to content

Commit

Permalink
Merge pull request #494 from jgravois/dont-remove-url-spaces
Browse files Browse the repository at this point in the history
fix cleanUrl regex so that spaces in folder names arent trimmed
  • Loading branch information
jgravois committed Mar 26, 2015
2 parents 24315aa + 01b0477 commit c8b3349
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions spec/UtilSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ describe('L.esri.Util', function () {
expect(url).to.equal('http://arcgis.com/');
});

it('shouldnt trim spaces in the middle', function(){
var url = L.esri.Util.cleanUrl(' http://arcgis.com/cool folder/anotherfolder ');
expect(url).to.equal('http://arcgis.com/cool folder/anotherfolder/');
});

it('should convert a GeoJSON Point to an ArcGIS Point', function() {
var input = {
'type': 'Point',
Expand Down
5 changes: 3 additions & 2 deletions src/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,10 @@
return featureCollection;
};

// trim whitespace and add a tailing slash is needed to a url
// trim url whitespace and add a trailing slash if needed
EsriLeaflet.Util.cleanUrl = function(url){
url = url.replace(/\s\s*/g, '');
//trim leading and trailing spaces, but not spaces inside the url
url = url.replace(/^\s+|\s+$|\A\s+|\s+\z/g, '');

//add a trailing slash to the url if the user omitted it
if(url[url.length-1] !== '/'){
Expand Down

0 comments on commit c8b3349

Please sign in to comment.