CJVT updates August and September 2026
This commit is contained in:
@@ -22,6 +22,19 @@ exports.removeHtmlTags = text => {
|
||||
return tagFilter.process(text)
|
||||
}
|
||||
|
||||
// Escapes Postgres LIKE metacharacters (\, %, _) in a raw search string so
|
||||
// it's matched literally rather than as a LIKE pattern - e.g. a user
|
||||
// searching for a dictionary literally named "100%" gets that dictionary,
|
||||
// not every dictionary. Backslash must be escaped first, or the escapes
|
||||
// added for % and _ below would themselves get re-escaped.
|
||||
//
|
||||
// Wildcard search (*, ?), if ever added: translate user-facing '*' -> '%'
|
||||
// and '?' -> '_' AFTER calling this function, on its return value - that
|
||||
// way literal %, _, and \ in the search text stay literal while the
|
||||
// user's own * and ? become real SQL wildcards.
|
||||
exports.escapeLikePattern = value =>
|
||||
value.replace(/\\/g, '\\\\').replace(/%/g, '\\%').replace(/_/g, '\\_')
|
||||
|
||||
// Returns setting value by its name from table instance_settings.
|
||||
exports.getInstanceSetting = async settingName => {
|
||||
const settingCacheName = `${INSTANCE_SETTING_NAMESPACE}:${settingName}`
|
||||
|
||||
Reference in New Issue
Block a user