# Double link urls when pasting over bbcode \`\[url\` tags

**URL:** https://meta.discourse.org/t/double-link-urls-when-pasting-over-bbcode-url-tags/211102
**Category:** Bug
**Created:** [December 4, 2021, 3:22pm UTC](https://meta.discourse.org/t/double-link-urls-when-pasting-over-bbcode-url-tags/211102 "2021-12-04T15:22:46Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Slowhand](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/slowhand/32/57436_2.png) [@Slowhand](https://meta.discourse.org/u/Slowhand)
#### Post date: [December 4, 2021, 3:22pm UTC](https://meta.discourse.org/t/double-link-urls-when-pasting-over-bbcode-url-tags/211102/1 "2021-12-04T15:22:46Z")

</div>

Continuing the discussion from [Please don't double link urls if one pastes over a URL in markdown](https://meta.discourse.org/t/please-dont-double-link-urls-if-one-pastes-over-a-url-in-markdown/210793/15):

Yesterday, this was fixed on my site, but this morning it’s right back to making a double URL when I want to past over an existing one.

---

<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: [December 5, 2021, 11:44pm UTC](https://meta.discourse.org/t/double-link-urls-when-pasting-over-bbcode-url-tags/211102/3 "2021-12-05T23:44:38Z")

</div>

Can you reproduce this on meta? I wonder if you found a new edge case?

---

<div class="post-metadata">

### Author: ![Slowhand](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/slowhand/32/57436_2.png) [@Slowhand](https://meta.discourse.org/u/Slowhand)
#### Post date: [December 5, 2021, 11:58pm UTC](https://meta.discourse.org/t/double-link-urls-when-pasting-over-bbcode-url-tags/211102/4 "2021-12-05T23:58:54Z")

</div>

I had a link that started out with “## [url= [/url]”

[## [url=](https://www.animenewsnetwork.com/)

Then when I tried to copy/paste over the link, I get the above result. Puts it completely outside of the [url= [/url] coding.

And, yes, I just did that here on Meta

---

<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: [December 6, 2021, 12:01am UTC](https://meta.discourse.org/t/double-link-urls-when-pasting-over-bbcode-url-tags/211102/5 "2021-12-06T00:01:13Z")

</div>

Oh that is BBCODE links, we do not use them that commonly hence we did not build a heuristic for it.

We will get this sorted, maybe @gwwar can send through a PR?

Any reason you are leaning on BBCODE links vs Markdown ones? Mostly up to habit?

---

<div class="post-metadata">

### Author: ![Slowhand](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/slowhand/32/57436_2.png) [@Slowhand](https://meta.discourse.org/u/Slowhand)
#### Post date: [December 6, 2021, 1:31am UTC](https://meta.discourse.org/t/double-link-urls-when-pasting-over-bbcode-url-tags/211102/6 "2021-12-06T01:31:38Z")

</div>

> [@sam](#):
>
> Any reason you are leaning on BBCODE links vs Markdown ones? Mostly up to habit?

Yes, over 10 years worth of habit. I’ve tried to change, but my fingers will not listen.

---

<div class="post-metadata">

### Author: ![gwwar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gwwar/32/116586_2.png) [@gwwar](https://meta.discourse.org/u/gwwar)
#### Post date: [December 6, 2021, 3:49pm UTC](https://meta.discourse.org/t/double-link-urls-when-pasting-over-bbcode-url-tags/211102/7 "2021-12-06T15:49:56Z")

</div>

> [@sam](#):
>
> We will get this sorted, maybe @gwwar can send through a PR?

Sure, I can see if there’s a decent fix for this.

---

<div class="post-metadata">

### Author: ![gwwar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gwwar/32/116586_2.png) [@gwwar](https://meta.discourse.org/u/gwwar)
#### Post date: [December 6, 2021, 3:58pm UTC](https://meta.discourse.org/t/double-link-urls-when-pasting-over-bbcode-url-tags/211102/8 "2021-12-06T15:58:13Z")

</div>

Let’s see, so for my own reference, url and email bb tags work like the following. They may also support magic links, where the URI protocol doesn’t need to be specified.

```plaintext
[url=][/url]
[url=https://www.phpbb.com/]Visit phpBB![/url]
[url]https://www.phpbb.com/[/url]
[email]example@example[/email]

```

[https://www.phpbb.com/community/help/bbcode](https://www.phpbb.com/community/help/bbcode)

Behavior-wise, I think it’d be reasonable to test if a text-selection contains a bbcode email or url tag. Depending on what folks run into, we could also widen the test to default to default paste behavior if we detect any bbcode tags.

---

<div class="post-metadata">

### Author: ![gwwar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gwwar/32/116586_2.png) [@gwwar](https://meta.discourse.org/u/gwwar)
#### Post date: [December 6, 2021, 6:17pm UTC](https://meta.discourse.org/t/double-link-urls-when-pasting-over-bbcode-url-tags/211102/9 "2021-12-06T18:17:35Z")

</div>

I added a PR here. Let me know if this isn’t the use case folks were thinking of.

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

---

<div class="post-metadata">

### Author: ![Slowhand](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/slowhand/32/57436_2.png) [@Slowhand](https://meta.discourse.org/u/Slowhand)
#### Post date: [December 9, 2021, 3:03pm UTC](https://meta.discourse.org/t/double-link-urls-when-pasting-over-bbcode-url-tags/211102/10 "2021-12-09T15:03:48Z")

</div>

Sorry to bring this up again, but is there some timeline for when this will be fixed? I know sometimes it takes a few days, but this is still happening as of this morning.

---

<div class="post-metadata">

### Author: ![gwwar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gwwar/32/116586_2.png) [@gwwar](https://meta.discourse.org/u/gwwar)
#### Post date: [December 9, 2021, 3:50pm UTC](https://meta.discourse.org/t/double-link-urls-when-pasting-over-bbcode-url-tags/211102/11 "2021-12-09T15:50:17Z")

</div>

The PR was approved, but needs a Discourse Team member to merge. @eviltrout were we waiting on any other feedback?

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [December 9, 2021, 4:00pm UTC](https://meta.discourse.org/t/double-link-urls-when-pasting-over-bbcode-url-tags/211102/12 "2021-12-09T16:00:30Z")

</div>

@Slowhand can I just double check, how much of the `[url` tag are you highlighting before pasting? If I’m understanding it correctly, I think think @gwwar’s PR only covers option 1 below. Will that fix the issue for you?

* * *

Option 1:

```
This is a sentence with[url=discourse.org]A link[/url]
```

Option 2:

```
This is a sentence with [url=discourse.org]A link[/url]
```

Option 3:

```
This is a sentence with [url=discourse.org]A link[/url]
```

---

<div class="post-metadata">

### Author: ![Slowhand](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/slowhand/32/57436_2.png) [@Slowhand](https://meta.discourse.org/u/Slowhand)
#### Post date: [December 9, 2021, 4:07pm UTC](https://meta.discourse.org/t/double-link-urls-when-pasting-over-bbcode-url-tags/211102/13 "2021-12-09T16:07:29Z")

</div>

Option 2 is the one I’m having trouble with.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [December 9, 2021, 4:10pm UTC](https://meta.discourse.org/t/double-link-urls-when-pasting-over-bbcode-url-tags/211102/14 "2021-12-09T16:10:27Z")

</div>

Can you post an example starting point? With Option 2 exactly as I posted above, it seems to be working fine for me already, even without the new PR.

`discourse.org` is detected as an existing URL, and so the fancy pasting behaviour is bypassed 🤔

---

<div class="post-metadata">

### Author: ![Slowhand](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/slowhand/32/57436_2.png) [@Slowhand](https://meta.discourse.org/u/Slowhand)
#### Post date: [December 9, 2021, 4:21pm UTC](https://meta.discourse.org/t/double-link-urls-when-pasting-over-bbcode-url-tags/211102/15 "2021-12-09T16:21:57Z")

</div>

For Option 2, we have links to Daily specials from an anime site, so I usually just copy/paste the previous days’ links to a new post and then change them, saving me typing all that coding.

Example: this morning I copied yesterday’s deals

 ![image](https://global.discourse-cdn.com/meta/original/3X/a/2/a2a09da59f75598ff973018470608acf5e1c5675.png)

and pasted the links with today’s deals

 ![image](https://global.discourse-cdn.com/meta/original/3X/e/6/e68fdc9b5109e51118b139a0392a80615dfbd485.png)

causing this to happen:  
 ![image](https://global.discourse-cdn.com/meta/original/3X/1/d/1dd8a1a84a6b727ee21ce2894917647591583844.png)

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [December 9, 2021, 4:29pm UTC](https://meta.discourse.org/t/double-link-urls-when-pasting-over-bbcode-url-tags/211102/16 "2021-12-09T16:29:08Z")

</div>

If I select this

```
[url=https://www.rightstufanime.com/Some-Link]Text[/url]
```

And then paste

```plaintext
https://www.rightstufanime.com/Deca-Dence-Blu-ray

```

I end up with:
```
[url=https://www.rightstufanime.com/Deca-Dence-Blu-ray]Text[/url]
```

Could you see whether you can reproduce the issue you’re seeing here on Meta? (note that `[url` tags don’t actually render here, but you should still be able to try out the composer behavior)

Based on your last screenshot, I think you might be selecting the whole line, including the bullet point and the `[url=blah]test[/url]` wrapper? (i.e. almost the same as “Option 1” above)?

---

<div class="post-metadata">

### Author: ![Slowhand](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/slowhand/32/57436_2.png) [@Slowhand](https://meta.discourse.org/u/Slowhand)
#### Post date: [December 9, 2021, 4:36pm UTC](https://meta.discourse.org/t/double-link-urls-when-pasting-over-bbcode-url-tags/211102/17 "2021-12-09T16:36:45Z")

</div>

I can not reproduce the behavior here on Meta.

I don’t believe I’m selecting the whole line because I don’t want to have to retype all the coding. I would suppose that occasionally I might accidentally click the whole thing, but I’ve been very careful lately because of this problem.

But, let me ask you this, if I **AM** selecting the whole thing, is that the proper behavior? Instead of just putting in what I’m pasting, it adds it at the end and leaves what I originally highlighted?

Let me apologize again for not being very tech savvy, this is a little over my head.  
If I just really need to alter how I’m doing this, I will.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [December 9, 2021, 4:41pm UTC](https://meta.discourse.org/t/double-link-urls-when-pasting-over-bbcode-url-tags/211102/18 "2021-12-09T16:41:23Z")

</div>

> [@Slowhand](#):
>
> I can not reproduce the behavior here on Meta.

Ok that’s super interesting! Just to confirm, would you mind repro-ing one more time on your own forum? If there’s a difference, please do let us know so we can get to the bottom of it.

> [@Slowhand](#):
>
> But, let me ask you this, if I **AM** selecting the whole thing, is that the proper behavior?

I’d say ‘no’, it’s not the proper behaviour. We should absolutely fix it, and @gwwar’s PR does that. I just wanted to figure out exactly what the use-case was here to make sure we have all angles covered.

I’ll get that PR merged now, so it should be deployed to your site in the next few days @Slowhand

Thanks for bearing with me on all the questions! 😅

---

<div class="post-metadata">

### Author: ![Slowhand](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/slowhand/32/57436_2.png) [@Slowhand](https://meta.discourse.org/u/Slowhand)
#### Post date: [December 9, 2021, 4:47pm UTC](https://meta.discourse.org/t/double-link-urls-when-pasting-over-bbcode-url-tags/211102/19 "2021-12-09T16:47:26Z")

</div>

> [@david](#):
>
> Just to confirm, would you mind repro-ing one more time on your own forum? If there’s a difference

Nope, same thing.

Thanks so much for all your help!

---

<div class="post-metadata">

### Author: ![gwwar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gwwar/32/116586_2.png) [@gwwar](https://meta.discourse.org/u/gwwar)
#### Post date: [December 9, 2021, 5:44pm UTC](https://meta.discourse.org/t/double-link-urls-when-pasting-over-bbcode-url-tags/211102/20 "2021-12-09T17:44:23Z")

</div>

Note that option 2 should in theory be handled by

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

If folks still run into trouble with additional corner cases, it may make sense to add in a site or user setting to toggle the behavior.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [December 20, 2021, 8:00am UTC](https://meta.discourse.org/t/double-link-urls-when-pasting-over-bbcode-url-tags/211102/21 "2021-12-20T08:00:37Z")

</div>

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