Skip to content
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

Ability to make context-sensitive URL filtering #95

Closed
kornelski opened this issue May 3, 2018 · 3 comments
Closed

Ability to make context-sensitive URL filtering #95

kornelski opened this issue May 3, 2018 · 3 comments

Comments

@kornelski
Copy link
Contributor

kornelski commented May 3, 2018

UrlRelativeEvaluate is not aware of what kind of URL it is filtering. I need to rewrite image URLs <img src> differently than regular <a href> links.

Ideally I'd like to also filter absolute image URLs in order to force all images to load via a caching/anonymizing server for privacy. This is somewhat related to #59, but instead of blocking of image URLs I'd like to change them (and only image URLs, links aren't a problem for my use case).

A callback function that gets name of element and attribute would work for me.

@notriddle
Copy link
Member

notriddle commented May 3, 2018

The ideal way to do it would be to have the UrlRelativeEvaluate trait accept the three parameters (the tag, attribute, and URL) and just have it impl for the one-argument and three-argument closures. Unfortunately, that would be a breaking change.

So... Let's add another version (UrlRelativeEvaluateWithTag). The non-WithTag version will be kept around for back-compat until 2.0.

@kornelski
Copy link
Contributor Author

Could this be generalized to UrlEvaluate?

@notriddle
Copy link
Member

Now that you bring it up ... that's a good point. Your use case does require you to be able to preprocess all of the URLs, not just some of them.

So, yeah, this is completely separate from relative URL evaluation. So, there shouldn't be any deprecation or anything. Just a completely separate hook for URL postprocessing (which would run after relative URL evaluation) that is what you want to use for your camo links.

notriddle added a commit that referenced this issue May 3, 2018
kornelski added a commit to kornelski/tmp-pr-ammonia that referenced this issue May 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants