mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 12:50:38 -07:00
fix(url_decode): keep %2B as a literal plus when decoding (#939)
url_decode decoded the percent-encoding first and only then replaced "+" with a space, so a "%2B" became "+" and was immediately turned into a space. Any literal "+" was therefore lost when round-tripped through url_encode. I now replace "+" with a space before decodeURIComponent, which lines up with Ruby's CGI.unescape used by Shopify.
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { stringify } from '../util/underscore'
|
||||
|
||||
export const url_decode = (x: string) => decodeURIComponent(stringify(x)).replace(/\+/g, ' ')
|
||||
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, '+')
|
||||
|
||||
Reference in New Issue
Block a user