-
Notifications
You must be signed in to change notification settings - Fork 476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
finds a url inside a base64 encoded image string #117
Comments
.withinString() can't handle HTML. It never could, it never will. If you want to convert URLs to links on HTML content or the DOM, have a look at this example. Note that the example is using TreeWalker which is not available/fully supported in older browsers. |
its actually a string with HTML embedded in it. Before it gets added to the dom. I wonder if I can add it to the dom first, then filter on text nodes, and apy withinString to those nodes instead of the html string. |
that's exactly what the jsbin demo is supposed to show ;) let me know what you made of it. maybe we should add this method to URI.js' jQuery plugin? |
this is how i'm doing it now: https://gist.github.com/chovy/1e3f3df674e1557c230e pretty easy to filter by textnodes first. but my $message contains text which has |
well, you can establish context within the callback function like so: var text = "hello {{hello}} ((hello)) {{hello}} world";
text = text.replace(/(hello)/g, function(url) {
var original = arguments[arguments.length -1];
var start = arguments[arguments.length -2];
var length = url.length;
if (original.substring(start -2, start) !== '{{') {
return url;
}
if (original.substring(start + length, start + length + 2) !== '}}') {
return url;
}
return "within double curly braces";
}); so this could be used to see if your match is preceded by |
is there some kind of limit to the length of the url passed to the callback function for URI.withinString? I noticed that on larger files, they all seem to be truncated. around 65k characters. |
URI.js does not impose any limits. if there is something fishy, it may be RegExp itself. |
I don't know if this is intended or not, but its causing problems for me.
a base64 encoded image data url is being recognized as a url, so there ends up being a n anchor tag wrapped inside the src attribute of the image when using
If my text contains something like this:
Using this method
I end up with this:
...which obviously is invalid html.
The text was updated successfully, but these errors were encountered: