mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-19 06:20:38 -07:00
feat: escape filters from Jekyll, #443
This commit is contained in:
@@ -19,6 +19,10 @@ export function escape (str: string) {
|
||||
return stringify(str).replace(/&|<|>|"|'/g, m => escapeMap[m])
|
||||
}
|
||||
|
||||
export function xml_escape (str: string) {
|
||||
return escape(str)
|
||||
}
|
||||
|
||||
function unescape (str: string) {
|
||||
return stringify(str).replace(/&(amp|lt|gt|#34|#39);/g, m => unescapeMap[m])
|
||||
}
|
||||
|
||||
+8
-2
@@ -1,4 +1,10 @@
|
||||
import { stringify } from '../util/underscore'
|
||||
|
||||
export const url_decode = (x: string) => stringify(x).split('+').map(decodeURIComponent).join(' ')
|
||||
export const url_encode = (x: string) => stringify(x).split(' ').map(encodeURIComponent).join('+')
|
||||
export const url_decode = (x: string) => decodeURIComponent(stringify(x)).replace(/\+/g, ' ')
|
||||
export const url_encode = (x: string) => encodeURIComponent(stringify(x)).replace(/%20/g, '+')
|
||||
export const cgi_escape = (x: string) => encodeURIComponent(stringify(x))
|
||||
.replace(/%20/g, '+')
|
||||
.replace(/[!'()*]/g, c => '%' + c.charCodeAt(0).toString(16).toUpperCase())
|
||||
export const uri_escape = (x: string) => encodeURI(stringify(x))
|
||||
.replace(/%5B/g, '[')
|
||||
.replace(/%5D/g, ']')
|
||||
|
||||
Reference in New Issue
Block a user