@emeryld/rrroutes-server 2.5.0 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +37 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +37 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -138,6 +138,29 @@ var sanitizeValue = (value, options, depth, seen, req, target, path) => {
|
|
|
138
138
|
seen.delete(value);
|
|
139
139
|
return applyCustomSanitizer(objectTarget, options, context);
|
|
140
140
|
};
|
|
141
|
+
var findPropertyDescriptor = (source, key) => {
|
|
142
|
+
let cursor = source;
|
|
143
|
+
while (cursor) {
|
|
144
|
+
const descriptor = Object.getOwnPropertyDescriptor(cursor, key);
|
|
145
|
+
if (descriptor) return descriptor;
|
|
146
|
+
cursor = Object.getPrototypeOf(cursor);
|
|
147
|
+
}
|
|
148
|
+
return void 0;
|
|
149
|
+
};
|
|
150
|
+
var setRequestQuery = (req, value) => {
|
|
151
|
+
const queryDescriptor = findPropertyDescriptor(req, "query");
|
|
152
|
+
if (!queryDescriptor || queryDescriptor.writable || queryDescriptor.set) {
|
|
153
|
+
;
|
|
154
|
+
req.query = value;
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
Object.defineProperty(req, "query", {
|
|
158
|
+
configurable: true,
|
|
159
|
+
enumerable: true,
|
|
160
|
+
writable: true,
|
|
161
|
+
value
|
|
162
|
+
});
|
|
163
|
+
};
|
|
141
164
|
var createRequestSanitizationMiddleware = (options = {}) => {
|
|
142
165
|
const normalized = normalizeOptions(options);
|
|
143
166
|
return (req, _res, next) => {
|
|
@@ -153,16 +176,20 @@ var createRequestSanitizationMiddleware = (options = {}) => {
|
|
|
153
176
|
[]
|
|
154
177
|
);
|
|
155
178
|
}
|
|
156
|
-
if (normalized.targets.has("query")
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
179
|
+
if (normalized.targets.has("query")) {
|
|
180
|
+
const query = req.query;
|
|
181
|
+
if (query) {
|
|
182
|
+
const sanitizedQuery = sanitizeValue(
|
|
183
|
+
query,
|
|
184
|
+
normalized,
|
|
185
|
+
0,
|
|
186
|
+
/* @__PURE__ */ new WeakSet(),
|
|
187
|
+
req,
|
|
188
|
+
"query",
|
|
189
|
+
[]
|
|
190
|
+
);
|
|
191
|
+
setRequestQuery(req, sanitizedQuery);
|
|
192
|
+
}
|
|
166
193
|
}
|
|
167
194
|
if (normalized.targets.has("body") && req.body !== void 0) {
|
|
168
195
|
req.body = sanitizeValue(
|