Upgraded dependencies, bumped to Node 24.
This commit is contained in:
47
src/utils/query-boolean.js
Normal file
47
src/utils/query-boolean.js
Normal file
@@ -0,0 +1,47 @@
|
||||
function parseBoolFromString(string) {
|
||||
if (string === 'true') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (string === 'false') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
function parseValue(value) {
|
||||
if (typeof value === 'string') {
|
||||
return parseBoolFromString(value);
|
||||
}
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
return value.map(parseValue);
|
||||
}
|
||||
|
||||
if (value && typeof value === 'object') {
|
||||
return parseObject(value);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function parseObject(obj) {
|
||||
return Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, parseValue(value)]));
|
||||
}
|
||||
|
||||
// Express 5's req.query is a getter that re-parses the URL on every access, so it can no longer
|
||||
// be reassigned like `req.query = ...` (that's a silent no-op); it must be shadowed with its own
|
||||
// property on the request instance instead. See https://github.com/expressjs/express/issues/6633
|
||||
export default function queryBoolean() {
|
||||
return (req, _res, next) => {
|
||||
Object.defineProperty(req, 'query', {
|
||||
value: parseObject(req.query),
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
writable: true,
|
||||
});
|
||||
|
||||
next();
|
||||
};
|
||||
}
|
||||
@@ -39,7 +39,7 @@ const accentMap = {
|
||||
ỹ: 'y',
|
||||
};
|
||||
|
||||
const plainCharRegex = /[a-zA-Z0-9]/;
|
||||
const plainCharRegex = /[a-z0-9]/i;
|
||||
const defaultPunctuationRegex = /[.,?!:;&'‘’"“”…()[\]{}<>/*—]/;
|
||||
const defaultSymbolRegex = /[@$€£#%^+=\\~]/;
|
||||
|
||||
@@ -111,7 +111,8 @@ export default function slugify(strings, delimiter = '-', {
|
||||
}
|
||||
|
||||
return '';
|
||||
}).join('');
|
||||
})
|
||||
.join('');
|
||||
|
||||
const components = normalized.trim().split(/\s+/).filter(Boolean);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user