Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make `parseHash` handling the hash sign

Goals are:
- better design => parseHash parse the hash :)
- DRYer => you can call parseHash with location.hash directly, without needing
           to make the substr each time
  • Loading branch information...
commit 66f9c0084b1cdb109a87d0681b3d0d7da23b3326 1 parent 27c3549
@yohanboniface yohanboniface authored
Showing with 4 additions and 2 deletions.
  1. +4 −2 leaflet-hash.js
View
6 leaflet-hash.js
@@ -18,6 +18,9 @@
lastHash: null,
parseHash: function(hash) {
+ if(hash.indexOf('#') == 0) {
+ hash = hash.substr(1);
+ }
var args = hash.split("/");
if (args.length == 3) {
var zoom = parseInt(args[0], 10),
@@ -90,8 +93,7 @@
// console.info("(no change)");
return;
}
- var sansHash = hash.substr(1),
- parsed = this.parseHash(sansHash);
+ var parsed = this.parseHash(hash);
if (parsed) {
// console.log("parsed:", parsed.zoom, parsed.center.toString());
this.movingMap = true;
Please sign in to comment.
Something went wrong with that request. Please try again.