Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ export type QueryObject = Record<string, QueryValue | QueryValue[]>;

export type ParsedQuery = Record<string, string | string[]>;

const EmptyObject = /* @__PURE__ */ (() => {
const C = function () {};
C.prototype = Object.create(null);
return C;
})() as unknown as { new (): any };
// const EmptyObject = /* @__PURE__ */ (() => {
// const C = function () {};
// C.prototype = Object.create(null);
// return C;
// })() as unknown as { new (): any };

/**
* Parses and decodes a query string into an object.
Expand All @@ -37,7 +37,9 @@ const EmptyObject = /* @__PURE__ */ (() => {
export function parseQuery<T extends ParsedQuery = ParsedQuery>(
parametersString = "",
): T {
const object: ParsedQuery = new EmptyObject();
// TODO: Use new EmptyObject() instead of Object.create(null) for better performance in next major version
// https://github.com/unjs/ufo/pull/290
const object: ParsedQuery = Object.create(null);
if (parametersString[0] === "?") {
parametersString = parametersString.slice(1);
}
Expand Down