1
0
mirror of https://github.com/webrecorder/pywb.git synced 2025-03-15 00:03:28 +01:00

wombat improvements (2.16):

- rewrite_elem() also rewrite 'poster'
- extract_orig() don't add http:// if nothing extracted
- new override: navigator.sendBeacon() if available
This commit is contained in:
Ilya Kreymer 2016-09-14 14:13:59 -07:00
parent 5fede0fea3
commit cc65ce914d

View File

@ -18,7 +18,7 @@ This file is part of pywb, https://github.com/ikreymer/pywb
*/
//============================================
// Wombat JS-Rewriting Library v2.15
// Wombat JS-Rewriting Library v2.16
//============================================
@ -314,6 +314,8 @@ var wombat_internal = function($wbwindow) {
return "";
}
var orig_href = href;
// proxy mode: no extraction needed
if (!wb_replay_prefix) {
return href;
@ -348,7 +350,7 @@ var wombat_internal = function($wbwindow) {
href = href.substr(4);
}
if (!starts_with(href, VALID_PREFIXES)) {
if (href != orig_href && !starts_with(href, VALID_PREFIXES)) {
href = HTTP_PREFIX + href;
}
}
@ -1231,6 +1233,7 @@ var wombat_internal = function($wbwindow) {
changed = rewrite_attr(elem, "src");
changed = rewrite_attr(elem, "href") || changed;
changed = rewrite_attr(elem, "style") || changed;
changed = rewrite_attr(elem, "poster") || changed;
}
if (elem.getAttribute) {
@ -2209,6 +2212,20 @@ var wombat_internal = function($wbwindow) {
}
}
//============================================
function init_beacon_override()
{
if (!$wbwindow.navigator.sendBeacon) {
return;
}
var orig_sendBeacon = $wbwindow.navigator.sendBeacon;
$wbwindow.navigator.sendBeacon = function(url, data) {
return orig_sendBeacon.call(this, rewrite_url(url), data);
}
}
//============================================
function get_final_url(prefix, mod, url) {
if (mod == undefined) {
@ -2362,6 +2379,9 @@ var wombat_internal = function($wbwindow) {
// registerProtocolHandler override
init_registerPH_override();
//sendBeacon override
init_beacon_override();
// expose functions
this.extract_orig = extract_orig;
this.rewrite_url = rewrite_url;