Skip to content

Commit

Permalink
fix: [#1135] Adds support for returning URL relative to window locati…
Browse files Browse the repository at this point in the history
…on in HTMLLinkElement.href, HTMLImageElement.src and HTMLScriptElement.src
  • Loading branch information
capricorn86 committed Mar 13, 2024
1 parent 713aa3c commit 80f8591
Show file tree
Hide file tree
Showing 16 changed files with 246 additions and 259 deletions.
14 changes: 1 addition & 13 deletions packages/happy-dom/src/browser/utilities/BrowserFrameURL.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import IBrowserFrame from '../types/IBrowserFrame.js';
import DOMException from '../../exception/DOMException.js';
import DOMExceptionNameEnum from '../../exception/DOMExceptionNameEnum.js';
import { URL } from 'url';

/**
Expand All @@ -24,17 +22,7 @@ export default class BrowserFrameURL {
try {
return new URL(url, frame.window.location.href);
} catch (e) {
if (frame.window.location.hostname) {
throw new DOMException(
`Failed to construct URL from string "${url}".`,
DOMExceptionNameEnum.uriMismatchError
);
} else {
throw new DOMException(
`Failed to construct URL from string "${url}" relative to URL "${frame.window.location.href}".`,
DOMExceptionNameEnum.uriMismatchError
);
}
return new URL('about:blank');
}
}
}

0 comments on commit 80f8591

Please sign in to comment.