diff app/assets/javascripts/zp.hash_magic.js @ 308:e855e58d137e

Always include current path when replacing state.
author edogawaconan <me@myconan.net>
date Wed, 19 Feb 2014 20:21:20 +0900
parents 77c157a9e645
children 4b91c0c1938c
line wrap: on
line diff
--- a/app/assets/javascripts/zp.hash_magic.js	Wed Feb 19 19:53:42 2014 +0900
+++ b/app/assets/javascripts/zp.hash_magic.js	Wed Feb 19 20:21:20 2014 +0900
@@ -17,10 +17,9 @@
       }
       var
         format = zp.formatter.current(),
-        hash = "#"
-      hash += format
-      if (hash === "#pl") { hash = " " }
-      history.replaceState(null, "", hash)
+        newpath = window.location.pathname
+      if (format !== "pl") { newpath += "#" + format }
+      history.replaceState(null, "", newpath)
     },
     init: function() {
       if (!$("#paste").length) return