Watch Words Replace - Link

Hi I have recently used Watch Words Replace function as the old theme component Linkify words

This works great. However I have been notified by a user he receives a warning nag pop up that the link has already been used in a topic. As the member is not posting.a link. It is a system function. The user should not have this inconvenience.

4 Likes

Oh, this is a very interesting edge case. I support improving this.

2 Likes

Thank you for the bug report. A fix for this edge case was implemented in this PR:

4 Likes

Your welcome and thanks for the speedy fix.

:beers::sunglasses::+1::sparkles:

Only other minor issue I had found is that if a word link replacement is part of a username the @mention part of there name is replaced with link.

1 Like

I think that has been fixed recently?

https://github.com/discourse/discourse/pull/14260

Update

I’ve just checked on my test site, and while it shows a match&replace in the test box, in a ‘real’ post it does not make the replacement. (watched word to replace = *one)

1 Like

It mist be very recent as I had to disable 1 link.

Will test and let you know. Thanks.

1 Like

Okay here is my test after implementing lnk for pimax. User pimaxquorra part of his name is replaced with lnk

Running Stable

1 Like

Ah, that may be why. I’m on tests-passed, and that one gets more frequent updates.

Though I notice that your link only targets a portion of the username/word rather than the whole lot as mine did. I wonder if you’ve also got ‘watched words are regular expressions’ set as well? That may have an effect.

1 Like

In setting i have it as follows

Watched Word: pimax

Replace is the Link.

Is there a way to have the argument only Target the word alone?

Ie ‘pimax’ = lnk replacement
‘pimaxes’ = no replace as it has extra

Same with usernanes ir other compound or hyvenated words.

I have Steam setup as a link and with SteamVR it replaces the Steam part of SteamVR as a link.

1 Like

I realized that the problem was when watched_words_regular_expression was enabled. I think I have a better fix for this problem in place and it will be available in tests-passed once the PR is merged:

4 Likes

Awesome. Though will need to wait for these to roll out to stable.

Thanks very responsive and speedy with fixes.

:beers::sunglasses::+1::sparkles:

1 Like

Without watched words regular expressions set it actually does that automatically. I had to add wildcards * to catch a word that was part of a username/longer word.

With the regular expressions you can do it with boundaries (\b). So \bsteam\b would only catch ‘steam’ and not ‘steamVR’ or ‘somethingsteam’.

I can replicate the partial substitution if I have watched words regular expressions set in the admin settings, so it may be worth a check?

1 Like

Okay checked in both Stable and Tests passed.

Stable only has Replace no separate link setting in Watched Words.

With or without regular expression turned on the replace watched words doesn’t work with the /bword/b. In fact you need to add the /bword/b for word to be recognized instead of just word

Test Passed works without needing the /bword/b in Link watched words.

So looks like just need to wait for Tests Passed to roll out to Stable.

1 Like

Ah, I thought it was only the @mentions fix you were missing. Oh well, the Watched Words revamp sounds like it’s got a few useful tweaks for you when you get it. :slightly_smiling_face: Hopefully it won’t be long. :crossed_fingers:

1 Like

Indeed can play with some of the new stuff on our test passed testing server. Unfortunately our main is using stable. There are a number of improvements that I can’t wait to be available on stable branch. :star_struck:

1 Like

This topic was automatically closed after 2 days. New replies are no longer allowed.