| 40 | * ``` |
| 41 | */ |
| 42 | export class SvelteURL extends URL { |
| 43 | #protocol = state(super.protocol); |
| 44 | #username = state(super.username); |
| 45 | #password = state(super.password); |
| 46 | #hostname = state(super.hostname); |
| 47 | #port = state(super.port); |
| 48 | #pathname = state(super.pathname); |
| 49 | #hash = state(super.hash); |
| 50 | #search = state(super.search); |
| 51 | #searchParams; |
| 52 | |
| 53 | /** |
| 54 | * @param {string | URL} url |
| 55 | * @param {string | URL} [base] |
| 56 | */ |
| 57 | constructor(url, base) { |
| 58 | url = new URL(url, base); |
| 59 | super(url); |
| 60 | |
| 61 | if (DEV) { |
| 62 | tag(this.#protocol, 'SvelteURL.protocol'); |
| 63 | tag(this.#username, 'SvelteURL.username'); |
| 64 | tag(this.#password, 'SvelteURL.password'); |
| 65 | tag(this.#hostname, 'SvelteURL.hostname'); |
| 66 | tag(this.#port, 'SvelteURL.port'); |
| 67 | tag(this.#pathname, 'SvelteURL.pathname'); |
| 68 | tag(this.#hash, 'SvelteURL.hash'); |
| 69 | tag(this.#search, 'SvelteURL.search'); |
| 70 | } |
| 71 | |
| 72 | current_url = this; |
| 73 | this.#searchParams = new SvelteURLSearchParams(url.searchParams); |
| 74 | current_url = null; |
| 75 | } |
| 76 | |
| 77 | get hash() { |
| 78 | return get(this.#hash); |
| 79 | } |
| 80 | |
| 81 | set hash(value) { |
| 82 | super.hash = value; |
| 83 | set(this.#hash, super.hash); |
| 84 | } |
| 85 | |
| 86 | get host() { |
| 87 | get(this.#hostname); |
| 88 | get(this.#port); |
| 89 | return super.host; |
| 90 | } |
| 91 | |
| 92 | set host(value) { |
| 93 | super.host = value; |
| 94 | set(this.#hostname, super.hostname); |
| 95 | set(this.#port, super.port); |
| 96 | } |
| 97 | |
| 98 | get hostname() { |
| 99 | return get(this.#hostname); |