Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix cleanUrl regex so that spaces in folder names arent trimmed #494

Merged
merged 1 commit into from
Mar 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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