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

urlpreview: Don't fetch previews for URLs in code blocks #5

Open
peterrus opened this issue Aug 21, 2023 · 2 comments
Open

urlpreview: Don't fetch previews for URLs in code blocks #5

peterrus opened this issue Aug 21, 2023 · 2 comments

Comments

@peterrus
Copy link
Contributor

peterrus commented Aug 21, 2023

When someone embeds an URL in a code block (backtick or triple backtick) we probably shouldn't try to fetch a preview because that URL is there for different purposes than a regular URL that is posted to a channel.

I tried to do this with a regex, but my regex wizardry doesn't cut it unfortunately.

@coffeebank
Copy link
Owner

Thinking a possible way is to run two Regex commands:

  1. The first one remains the same, parsing all instances of https://
  2. The second one parses for all instances of (`|```) ... https:// ... (`|```) and returning the urls

Then, for every Regex 1 result, if result is in Regex 2, we ignore it

Downsides: Very inefficient, fails if users use ` as a regular quote, relies on parsing ` specifically (and not <pre> <code> etc.)

@peterrus
Copy link
Contributor Author

Yeah this one seems quite hard. Maybe someone comes along with a good idea!

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