import { URL } from 'url'; import DOMException from '../exception/DOMException.js'; import DOMExceptionNameEnum from '../exception/DOMExceptionNameEnum.js'; /** * */ export default class Location extends URL { /** * Constructor. */ constructor() { super('about:blank'); } /** * Override set href. */ // @ts-ignore set href(value) { try { super.href = this.hostname ? new URL(value, this).href : value; } catch (e) { if (this.hostname) { throw new DOMException(`Failed to construct URL from string "${value}".`, DOMExceptionNameEnum.uriMismatchError); } else { throw new DOMException(`Failed to construct URL from string "${value}" relative to URL "${super.href}".`, DOMExceptionNameEnum.uriMismatchError); } } } /** * Override set href. */ get href() { return super.href; } /** * Replaces the current resource with the one at the provided URL. The difference from the assign() method is that after using replace() the current page will not be saved in session History, meaning the user won't be able to use the back button to navigate to it. * * @param url URL. */ replace(url) { this.href = url; } /** * Loads the resource at the URL provided in parameter. * * Note: Will do the same thing as "replace()" as server-dom does not support loading the URL. * * @param url * @see this.replace() */ assign(url) { this.href = url; } /** * Reloads the resource from the current URL. * * Note: Will do nothing as reloading is not supported in server-dom. */ reload() { // Do nothing } } //# sourceMappingURL=Location.js.map