diff options
Diffstat (limited to 'ext/fetch/20_headers.js')
-rw-r--r-- | ext/fetch/20_headers.js | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/ext/fetch/20_headers.js b/ext/fetch/20_headers.js index b99758de5..d03751d08 100644 --- a/ext/fetch/20_headers.js +++ b/ext/fetch/20_headers.js @@ -26,7 +26,9 @@ const { ArrayPrototypeSort, ArrayPrototypeJoin, ArrayPrototypeSplice, + ObjectFromEntries, ObjectHasOwn, + ObjectPrototypeIsPrototypeOf, RegExpPrototypeTest, Symbol, SymbolFor, @@ -441,13 +443,14 @@ class Headers { } } - [SymbolFor("Deno.privateCustomInspect")](inspect) { - const headers = {}; - // deno-lint-ignore prefer-primordials - for (const header of this) { - headers[header[0]] = header[1]; + [SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) { + if (ObjectPrototypeIsPrototypeOf(HeadersPrototype, this)) { + return `${this.constructor.name} ${ + inspect(ObjectFromEntries(this), inspectOptions) + }`; + } else { + return `${this.constructor.name} ${inspect({}, inspectOptions)}`; } - return `Headers ${inspect(headers)}`; } } |