af/JSnoX

Allowing Richer Character Set in Spec String

Closed this issue · 3 comments

I am running into an issue with using Google's Static Maps API. I'm trying to put a long URL into the src of an img tag. This url contains equal signs and screws up JSnoX parsing. Here is an example URL: https://maps.googleapis.com/maps/api/staticmap?center=San+Francisco,CA&zoom=10&size=400x400

The JSnoX code inside of the React render function should look like this:
d('img[src="https://maps.googleapis.com/maps/api/staticmap?center=San+Francisco,CA&zoom=10&size=400x400"]') assuming d is my JSnoX wrapper.

When rendered into html it looks like this (no recognized src tag):
<img class="className" data-reactid=".0.$div=1main.$div=1details-box.$div=1map.$img[src=0https=2//maps=1googleapis=1com/maps/api/staticmap?center=0San+Francisco,CA&amp;zoom=010&amp;size=0400x400]">

instead of the expected (with src tag):
<img src="https://maps.googleapis.com/maps/api/staticmap?center=San+Francisco,CA&zoom=10&size=400x400" class="className" data-reactid=".0.$div=1main.$div=1details-box.$div=1map.$img[src=0https=2//maps=1googleapis=1com/maps/api/staticmap?center=0San+Francisco,CA&amp;zoom=010&amp;size=0400x400]">

This is apparently due to the use of multiple equal signs in the URL.

af commented

Hi, good find! Should be able to fix this by updating the propsRegex and attrsRegex. I took a quick (unsuccessful) stab at it just now but hopefully will be able to sort it out tomorrow.

af commented

@maprules1000 That should do it, let me know if this still gives you problems. Can push this as v1.0.1 if you need to get a pinned version from npm.

Works great! Thanks for the quick fix!