From 80c5b45178100f4931ba5fb4dedf41668715c5b7 Mon Sep 17 00:00:00 2001 From: Ilya Kreymer Date: Sat, 13 Dec 2014 23:12:42 -0800 Subject: [PATCH 1/2] wb.js: don't include anchor when comparing current url with expected top url --- pywb/static/wb.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pywb/static/wb.js b/pywb/static/wb.js index f6b2fb41..1974c59f 100644 --- a/pywb/static/wb.js +++ b/pywb/static/wb.js @@ -128,7 +128,10 @@ this.load = function() { window._wb_js_inited = true; if ((window.self == window.top) && wbinfo) { - if (wbinfo.top_url && (window.location.href != wbinfo.top_url) && wbinfo.mod != "bn_") { + + var loc = window.location.href.replace(window.location.hash, ""); + + if (wbinfo.top_url && (loc != wbinfo.top_url) && wbinfo.mod != "bn_") { // Auto-redirect to top frame window.location.replace(wbinfo.top_url); } else { From 09861ada2ce1bdc6ca1c567672500e74219c62b7 Mon Sep 17 00:00:00 2001 From: Ilya Kreymer Date: Sat, 13 Dec 2014 23:19:04 -0800 Subject: [PATCH 2/2] wb.js: preserve anchor in location redirect update CHANGELIST --- CHANGES.rst | 2 ++ pywb/static/wb.js | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index b3b2bf6d..6a4f8439 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,8 @@ pywb 0.6.6 changelist ~~~~~~~~~~~~~~~~~~~~~ +* JS client side improvements: check for double-inits, preserve anchor in wb.js top location redirect + * JS Rewriters: add mixins for link + location (default), link only, location only rewriting by setting ``js_rewrite_location`` to ``all``, ``urls``, ``location``, respectively. (New: location only rewriting does not change JS urls) diff --git a/pywb/static/wb.js b/pywb/static/wb.js index 1974c59f..ea14c9fa 100644 --- a/pywb/static/wb.js +++ b/pywb/static/wb.js @@ -129,11 +129,13 @@ this.load = function() { if ((window.self == window.top) && wbinfo) { + var hash = window.location.hash; + var loc = window.location.href.replace(window.location.hash, ""); if (wbinfo.top_url && (loc != wbinfo.top_url) && wbinfo.mod != "bn_") { // Auto-redirect to top frame - window.location.replace(wbinfo.top_url); + window.location.replace(wbinfo.top_url + hash); } else { // Init Banner (no frame or top frame) add_event("readystatechange", init_banner, document);