diff options
Diffstat (limited to 'cli/js/url.ts')
-rw-r--r-- | cli/js/url.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/cli/js/url.ts b/cli/js/url.ts index f22198da4..7b06fd64c 100644 --- a/cli/js/url.ts +++ b/cli/js/url.ts @@ -3,6 +3,7 @@ import * as urlSearchParams from "./url_search_params.ts"; import * as domTypes from "./dom_types.ts"; import { getRandomValues } from "./get_random_values.ts"; import { window } from "./window.ts"; +import { customInspect } from "./console.ts"; interface URLParts { protocol: string; @@ -144,6 +145,26 @@ export class URL { private _parts: URLParts; private _searchParams!: urlSearchParams.URLSearchParams; + [customInspect](): string { + const keys = [ + "href", + "origin", + "protocol", + "username", + "password", + "host", + "hostname", + "port", + "pathname", + "hash", + "search" + ]; + const objectString = keys + .map((key: string) => `${key}: "${this[key] || ""}"`) + .join(", "); + return `URL { ${objectString} }`; + } + private _updateSearchParams(): void { const searchParams = new urlSearchParams.URLSearchParams(this.search); |