The discussion revolves around the limitations of Discourse’s censor feature when handling links. Ed_Bobkov seeks a way to automatically censor and block specific links by replacing them with a blocked version, noting that the current censor function only hides visible text and doesn’t break links, especially when onebox is enabled. pfaffman suggests adjusting trust levels, but Ed_Bobkov clarifies the need for automated link replacement via regex. He shares a regex pattern to target links from a specific domain but notes it fails in practice and is constrained by a 50-character limit. Sailsman63 questions the need for censorship if users are allowed to post such links, while codinghorror explains that censoring is intended for text, not links, and recommends blocking instead. The thread references a past issue where link censoring worked differently, highlighting a change in functionality.
How can I automatically censor specific links in new posts?
The best solution for me would be censoring links. But the current “Censor” function hides only visible text and the link is working as if it wasn’t censored.
And when onebox is activated then Cersoring doesn’t work completely - nothing is hidden.
Thanks, Jay! But the idea is to auto change censored words and links. That’s strange that Discourse censors words in plain text and doesn’t change URL addresses.
Out of curiosity, if you have community members that are in the habit of “Spamming” links that are inappropriate for your community, why are they still members of your community? On the surface, this seems more like a moderation issue…
We do moderation but it takes time and is manual work.
I’d like to use a regex pattern to destroy specific links. Can anybody help me to construct a regex pattern for a link like this?
[text phrases](link to any page on a specific domain)
In my case [text phrases] may have different text versions and I would leave it original.
I need to hide only this part: (link to a page on a specific domain) where the domain is always the same, but the length and text of the link may be different.
The result should be like this:
[text phrases]■■■■■■■■■■■■■■■■■■■■■■■■
I found the topic, that previously censor function worked the way I need, but lately was changed: Censored words out of a URL
Created a regex pattern (\[.*?\])\(https?://((www\.site\.com)).*/?\)
When I test it in “Test ‘Censor’ Watched Words”, the system finds the necessary part.
But it doesn’t work when I add the text to be replaced in the post.
What may cause it?
Another problem is that there is a restriction of the expression length - no more than 50 characters. Is it possible to increase it?