changeset 308:e855e58d137e

Always include current path when replacing state.
author edogawaconan <me@myconan.net>
date Wed, 19 Feb 2014 20:21:20 +0900
parents 1a409564ffad
children 9fe8c29c27c4
files app/assets/javascripts/zp.hash_magic.js
diffstat 1 files changed, 3 insertions(+), 4 deletions(-) [+]
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