mirror of
https://github.com/Nezumi-2711/onedrive-vercel-index.git
synced 2026-09-22 13:38:45 +00:00
some housekeeping
This commit is contained in:
+11
-2
@@ -9,10 +9,19 @@ import siteConfig from '../../config/site.config'
|
||||
* Sanitize the search query
|
||||
*
|
||||
* @param query User search query, which may contain special characters
|
||||
* @returns Sanitised query string which encodes the '<' and '>' characters, replaces '?' and '/' characters with ' ', and replaces ''' with '''' accroading to https://stackoverflow.com/questions/41491222/single-quote-escaping-in-microsoft-graph.
|
||||
* @returns Sanitised query string, which:
|
||||
* - encodes the '<' and '>' characters,
|
||||
* - replaces '?' and '/' characters with ' ',
|
||||
* - replaces ''' with ''''
|
||||
* Reference: https://stackoverflow.com/questions/41491222/single-quote-escaping-in-microsoft-graph.
|
||||
*/
|
||||
function sanitiseQuery(query: string): string {
|
||||
const sanitisedQuery = query.replace(/'/g, "''").replace('<', ' < ').replace('>', ' > ').replace('?', ' ').replace('/', ' ')
|
||||
const sanitisedQuery = query
|
||||
.replace(/'/g, "''")
|
||||
.replace('<', ' < ')
|
||||
.replace('>', ' > ')
|
||||
.replace('?', ' ')
|
||||
.replace('/', ' ')
|
||||
return encodeURIComponent(sanitisedQuery)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user