From 950673908dc0eeb6fc13992378d87926ddc2eac7 Mon Sep 17 00:00:00 2001 From: Ilya Kreymer Date: Mon, 21 Jul 2014 14:41:49 -0700 Subject: [PATCH] proxy: fix wombat.js to work in proxy mode! rewrite only https -> http --- pywb/static/wombat.js | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/pywb/static/wombat.js b/pywb/static/wombat.js index 9c6ba1c0..e14c9d7d 100644 --- a/pywb/static/wombat.js +++ b/pywb/static/wombat.js @@ -121,6 +121,15 @@ WB_wombat_init = (function() { return url; } + // proxy mode: If no wb_replay_prefix, only rewrite https:// -> http:// + if (!wb_replay_prefix) { + if (starts_with(url, HTTPS_PREFIX)) { + return HTTP_PREFIX + url.substr(HTTPS_PREFIX.length); + } else { + return url; + } + } + // just in case wombat reference made it into url! url = url.replace("WB_wombat_", ""); @@ -181,6 +190,11 @@ WB_wombat_init = (function() { return ""; } + // proxy mode: no extraction needed + if (!wb_replay_prefix) { + return href; + } + href = href.toString(); var index = href.indexOf("/http", 1); @@ -683,20 +697,22 @@ WB_wombat_init = (function() { //============================================ function wombat_init(replay_prefix, capture_date, orig_scheme, orig_host, timestamp) { wb_replay_prefix = replay_prefix; - - wb_replay_date_prefix = replay_prefix + capture_date + "em_/"; - if (capture_date.length > 0) { - wb_capture_date_part = "/" + capture_date + "/"; - } else { - wb_capture_date_part = ""; + if (wb_replay_prefix) { + wb_replay_date_prefix = replay_prefix + capture_date + "em_/"; + + if (capture_date.length > 0) { + wb_capture_date_part = "/" + capture_date + "/"; + } else { + wb_capture_date_part = ""; + } + + wb_orig_scheme = orig_scheme + '://'; + + wb_orig_host = wb_orig_scheme + orig_host; + + init_bad_prefixes(replay_prefix); } - - wb_orig_scheme = orig_scheme + '://'; - - wb_orig_host = wb_orig_scheme + orig_host; - - init_bad_prefixes(replay_prefix); // Location var wombat_location = new WombatLocation(window.self.location);