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

Wombat Improvements for extractOriginalUrl and hash change (#481)

* wombat fixes:
- extractOriginalUrl() now takes into account the abs or rel prefix, if available, in determining the original url
- receive_hash_change() for 'outer_hashchange' message handling is now before MessageEvent override, fix to get the original message and check .from_top directly to determine if it originated with top frame.
This commit is contained in:
Ilya Kreymer 2019-06-22 09:47:55 -07:00 committed by GitHub
parent f7ecdd8d3b
commit 7cf5828cdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -906,8 +906,16 @@ Wombat.prototype.extractOriginalURL = function(rewrittenUrl) {
return url;
}
// if no coll, start from beginning, otherwise could be part of coll..
var start = this.wb_rel_prefix ? 1 : 0;
var start;
if (this.startsWith(url, this.wb_abs_prefix)) {
start = this.wb_abs_prefix.length;
} else if (this.wb_rel_prefix && this.startsWith(url, this.wb_rel_prefix)) {
start = this.wb_rel_prefix.length;
} else {
// if no coll, start from beginning, otherwise could be part of coll..
start = this.wb_rel_prefix ? 1 : 0;
}
var index = url.indexOf('/http', start);
if (index < 0) {
@ -4774,13 +4782,12 @@ Wombat.prototype.initHashChange = function() {
var wombat = this;
var receive_hash_change = function receive_hash_change(event) {
var source = wombat.proxyToObj(event.source);
if (!event.data || source !== wombat.$wbwindow.__WB_top_frame) {
if (!event.data || !event.data.from_top) {
return;
}
var message = event.data;
var message = event.data.message;
if (!message.wb_type) return;