DEV: Merge category and tag hashtags code paths (PR #10216)

Category and tag hashtags used to be handled differently even though most of the code was very similar. This design was the root cause of multiple issues related to hashtags.

This commit reduces the number of requests (just one and debounced better), removes the use of CSS classes which marked resolved hashtags, simplifies a lot of the code as there is a single source of truth and previous race condition fixes are now useless.

It also includes a very minor security fix which let unauthorized users to guess hidden tags.


Wouldn’t it be faster if we used a hash {} instead of an array []?

Can probably be a one-liner

  const slugs = $, hashtag) =>$(hashtag).text().substr(1));

Should we have a limit in order in the number of slugs in order to prevent DoS if Category.query_from_hashtag_slug is a slow operation?

Do we need to load the whole Category object just to return the url later on?

I thought the same, but last time I checked, prettier did not agree.

Yes, that’s right. I will use a Set instead.

Good point.

can we avoid using jquery here ?

can we use the .uniq() of Ember instead?

didnt check but what happens during tests with these? are they filled?

Can you use pluck instead?

Category#url uses the parent_category field.

A rate limit is kinda like using a rocket launcher to kill a fly.

I was thinking of just testing the size of params[:slug] and limiting it to a “decent” value. (just because I don’t trust the “user”)

I see, might want to add a comment then.

Also, does this work with sub-sub-categories?

Can we do this instead?

  const slugs = [...$, hashtag) => hashtag.innerText.substr(1))];

Added the comment and yes, it does.