Skip to content

Commit 31ea74c

Browse files
authored
fix(query): use Object.create(null) (#290)
1 parent 5b87427 commit 31ea74c

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/query.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ export type QueryObject = Record<string, QueryValue | QueryValue[]>;
1818

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

21-
const EmptyObject = /* @__PURE__ */ (() => {
22-
const C = function () {};
23-
C.prototype = Object.create(null);
24-
return C;
25-
})() as unknown as { new (): any };
21+
// const EmptyObject = /* @__PURE__ */ (() => {
22+
// const C = function () {};
23+
// C.prototype = Object.create(null);
24+
// return C;
25+
// })() as unknown as { new (): any };
2626

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

0 commit comments

Comments
 (0)