UNPKG

happy-dom-without-node

Version:

Happy DOM is a JavaScript implementation of a web browser without its graphical user interface. It includes many web standards from WHATWG DOM and HTML.

26 lines 656 B
import { URL } from '../../polyfills/url.js'; /** * Browser frame URL utility. */ export default class BrowserFrameURL { /** * Returns relative URL. * * @param frame Frame. * @param url URL. * @returns Relative URL. */ static getRelativeURL(frame, url) { url = url || 'about:blank'; if (url.startsWith('about:') || url.startsWith('javascript:')) { return new URL(url); } try { return new URL(url, frame.window.location.href); } catch (e) { return new URL('about:blank'); } } } //# sourceMappingURL=BrowserFrameURL.js.map