# Watch Words Replace - Link

**URL:** https://meta.discourse.org/t/watch-words-replace-link/207193
**Category:** Bug
**Tags:** watched-words
**Created:** [October 27, 2021, 12:40am UTC](https://meta.discourse.org/t/watch-words-replace-link/207193 "2021-10-27T00:40:55Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![Heliosurge](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/heliosurge/32/571810_2.png) [@Heliosurge](https://meta.discourse.org/u/Heliosurge)
#### Post date: [October 27, 2021, 12:40am UTC](https://meta.discourse.org/t/watch-words-replace-link/207193/1 "2021-10-27T00:40:55Z")

</div>

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.

 ![f501f7d115af7e89ad105cd132170e8dc14bac7c](https://global.discourse-cdn.com/meta/original/3X/f/5/f501f7d115af7e89ad105cd132170e8dc14bac7c.png)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [October 27, 2021, 6:30am UTC](https://meta.discourse.org/t/watch-words-replace-link/207193/2 "2021-10-27T06:30:21Z")

</div>

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

---

<div class="post-metadata">

### Author: ![nbianca](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nbianca/32/157984_2.png) [@nbianca](https://meta.discourse.org/u/nbianca)
#### Post date: [October 27, 2021, 2:02pm UTC](https://meta.discourse.org/t/watch-words-replace-link/207193/5 "2021-10-27T14:02:31Z")

</div>

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

[https://github.com/discourse/discourse/pull/14742](https://github.com/discourse/discourse/pull/14742)

---

<div class="post-metadata">

### Author: ![Heliosurge](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/heliosurge/32/571810_2.png) [@Heliosurge](https://meta.discourse.org/u/Heliosurge)
#### Post date: [October 27, 2021, 2:28pm UTC](https://meta.discourse.org/t/watch-words-replace-link/207193/6 "2021-10-27T14:28:54Z")

</div>

Your welcome and thanks for the speedy fix.

🍻😎👍✨

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.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [October 28, 2021, 7:42am UTC](https://meta.discourse.org/t/watch-words-replace-link/207193/7 "2021-10-28T07:42:32Z")

</div>

> [@Heliosurge](#):
>
> 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.

I think that has been fixed recently?

> <https://github.com/discourse/discourse/pull/14260>
>
> Watched words of type 'replace' or 'link' replaced the text inside
> mentions or …hashtags too, which broke these. These types of watched
> words must skip any match that has an @ or # before it.

**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)

 ![replace watched word](https://global.discourse-cdn.com/meta/original/3X/f/5/f5cadf8e1b71b3789e52cb00af5af26aed412ae7.jpeg)

 ![replace (in post)](https://global.discourse-cdn.com/meta/original/3X/e/6/e60b57abe3209f6fa2d5b682d3f7972cabe47a92.jpeg)

---

<div class="post-metadata">

### Author: ![Heliosurge](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/heliosurge/32/571810_2.png) [@Heliosurge](https://meta.discourse.org/u/Heliosurge)
#### Post date: [October 28, 2021, 1:24pm UTC](https://meta.discourse.org/t/watch-words-replace-link/207193/8 "2021-10-28T13:24:18Z")

</div>

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

Will test and let you know. Thanks.

---

<div class="post-metadata">

### Author: ![Heliosurge](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/heliosurge/32/571810_2.png) [@Heliosurge](https://meta.discourse.org/u/Heliosurge)
#### Post date: [October 28, 2021, 1:36pm UTC](https://meta.discourse.org/t/watch-words-replace-link/207193/9 "2021-10-28T13:36:24Z")

</div>

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

 ![Screenshots_2021-10-28-10-37-57](https://global.discourse-cdn.com/meta/original/3X/8/5/85c27dff87b1fa3ebce65b6b41620a556a3bdf3b.png)

Running Stable

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [October 28, 2021, 3:15pm UTC](https://meta.discourse.org/t/watch-words-replace-link/207193/10 "2021-10-28T15:15:53Z")

</div>

> [@Heliosurge](#):
>
> Running Stable

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

> [@2.7.7: Security Release](https://meta.discourse.org/t/2-7-7-security-release/197959/1):
>
> The “stable” branch is more focused on _lack of change_ than _lack of bugs_ - all releases, including those on tests-passed and beta are production ready.

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.

 ![watched word - link (*pimax*)](https://global.discourse-cdn.com/meta/original/3X/6/4/6494b28073972167963c22053e386db76a455c65.jpeg)

---

<div class="post-metadata">

### Author: ![Heliosurge](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/heliosurge/32/571810_2.png) [@Heliosurge](https://meta.discourse.org/u/Heliosurge)
#### Post date: [October 28, 2021, 3:26pm UTC](https://meta.discourse.org/t/watch-words-replace-link/207193/11 "2021-10-28T15:26:04Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![nbianca](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nbianca/32/157984_2.png) [@nbianca](https://meta.discourse.org/u/nbianca)
#### Post date: [October 28, 2021, 3:35pm UTC](https://meta.discourse.org/t/watch-words-replace-link/207193/12 "2021-10-28T15:35:55Z")

</div>

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:

[https://github.com/discourse/discourse/pull/14760](https://github.com/discourse/discourse/pull/14760)

---

<div class="post-metadata">

### Author: ![Heliosurge](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/heliosurge/32/571810_2.png) [@Heliosurge](https://meta.discourse.org/u/Heliosurge)
#### Post date: [October 28, 2021, 3:44pm UTC](https://meta.discourse.org/t/watch-words-replace-link/207193/13 "2021-10-28T15:44:05Z")

</div>

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

Thanks very responsive and speedy with fixes.

🍻😎👍✨

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [October 28, 2021, 4:14pm UTC](https://meta.discourse.org/t/watch-words-replace-link/207193/14 "2021-10-28T16:14:22Z")

</div>

> [@Heliosurge](#):
>
> Is there a way to have the argument only Target the word alone?

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?

---

<div class="post-metadata">

### Author: ![Heliosurge](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/heliosurge/32/571810_2.png) [@Heliosurge](https://meta.discourse.org/u/Heliosurge)
#### Post date: [October 28, 2021, 5:17pm UTC](https://meta.discourse.org/t/watch-words-replace-link/207193/15 "2021-10-28T17:17:59Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [October 28, 2021, 5:52pm UTC](https://meta.discourse.org/t/watch-words-replace-link/207193/16 "2021-10-28T17:52:15Z")

</div>

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. 🙂 Hopefully it won’t be long. 🤞

---

<div class="post-metadata">

### Author: ![Heliosurge](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/heliosurge/32/571810_2.png) [@Heliosurge](https://meta.discourse.org/u/Heliosurge)
#### Post date: [October 28, 2021, 6:42pm UTC](https://meta.discourse.org/t/watch-words-replace-link/207193/17 "2021-10-28T18:42:49Z")

</div>

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. 🤩

---

<div class="post-metadata">

### Author: ![nbianca](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nbianca/32/157984_2.png) [@nbianca](https://meta.discourse.org/u/nbianca)
#### Post date: [November 13, 2021, 8:00am UTC](https://meta.discourse.org/t/watch-words-replace-link/207193/18 "2021-11-13T08:00:41Z")

</div>

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