Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

uri encode shopify url to article

Tags:

shopify

liquid

Is there a way to uri encode a link in shopify:

http://www.tumblr.com/share?v=3&u={{ shop.url }}{{ article.url }}

Building out share buttons and tubmlr doesn't like that they are not encoded.

like image 979
keeg Avatar asked Nov 28 '22 17:11

keeg


2 Answers

Not sure if it was recently added, but url_param_escape seems to do exactly what you want. This worked for me:

{{ shop.url | append: article.url | url_param_escape }}

like image 52
andyvanee Avatar answered Jan 03 '23 02:01

andyvanee


My crude attempt is as follows:

{{ article.url | replace: ' ', '%20' | replace: '&', '%26' | replace: '?', '%3F' | replace: '!', '%21' | replace: ',', '%2C' | replace: "'", "%27" }}

and so on. I haven't mastered the art of writing liquid functions yet.

like image 39
Donn Edwards Avatar answered Jan 03 '23 03:01

Donn Edwards