Skip to content

Commit

Permalink
fix resolveRelUrl: don't try to create a rewriting parser from about:…
Browse files Browse the repository at this point in the history
…blank (and other disallowed prefixes)

default to window.document if passed in document does not have a valid URL (eg. about:blank)
specifically check for https:// or http://
fixes #139
  • Loading branch information
ikreymer committed Apr 8, 2024
1 parent 00c46c4 commit 91d6c35
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@webrecorder/wombat",
"version": "3.7.2",
"version": "3.7.3",
"main": "index.js",
"license": "AGPL-3.0-or-later",
"author": "Ilya Kreymer, Webrecorder Software",
Expand Down
5 changes: 4 additions & 1 deletion src/wombat.js
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,10 @@ Wombat.prototype.getFinalUrl = function(useRel, mod, url) {
* @return {string}
*/
Wombat.prototype.resolveRelUrl = function(url, doc) {
var docObj = doc || this.$wbwindow.document;
var docObj = this.$wbwindow.document;
if (doc && doc.baseURI && (doc.startsWith(HTTPS_PREFIX) || doc.startsWith(HTTP_PREFIX))) {
docObj = doc;
}
var parser = this.makeParser(docObj.baseURI, docObj);

return new this.URL(url, parser).href;
Expand Down

0 comments on commit 91d6c35

Please sign in to comment.