# Discourse 编码粘贴的 URL 片段

**URL:** https://meta.discourse.org/t/discourse-encodes-fragments-of-pasted-urls/137229
**Category:** Bug
**Created:** [2019年十二月28日 12:29 UTC](https://meta.discourse.org/t/discourse-encodes-fragments-of-pasted-urls/137229 "2019-12-28T12:29:54Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![svenefftinge](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/svenefftinge/32/164986_2.png) [@svenefftinge](https://meta.discourse.org/u/svenefftinge)
#### Post date: [2019年十二月28日 12:29 UTC](https://meta.discourse.org/t/discourse-encodes-fragments-of-pasted-urls/137229/1 "2019-12-28T12:29:54Z")

</div>

Discourse 会对粘贴的 URL 中的片段字符进行编码。

例如：  
`https://gitpod.io/#https://github.com/eclipse-theia/theia`  
会变为  
`https://gitpod.io/#https%3A%2F%2Fgithub.com%2Feclipse-theia%2Ftheia`

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2019年十二月28日 18:08 UTC](https://meta.discourse.org/t/discourse-encodes-fragments-of-pasted-urls/137229/2 "2019-12-28T18:08:39Z")

</div>

让我们看看

> **[Dashboard](https://gitpod.io/#https://github.com/eclipse-theia/theia)**

[Dashboard](https://gitpod.io/#https://github.com/eclipse-theia/theia)

所以您只引用单行 URL 吗？

---

<div class="post-metadata">

### Author: ![svenefftinge](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/svenefftinge/32/164986_2.png) [@svenefftinge](https://meta.discourse.org/u/svenefftinge)
#### Post date: [2019年十二月29日 08:22 UTC](https://meta.discourse.org/t/discourse-encodes-fragments-of-pasted-urls/137229/3 "2019-12-29T08:22:23Z")

</div>

啊，这里有两个链接。我没注意到。所以，是的，只有方框里的链接坏了。

---

<div class="post-metadata">

### Author: ![cvx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cvx/32/152146_2.png) [@cvx](https://meta.discourse.org/u/cvx)
#### Post date: [2019年十二月30日 08:46 UTC](https://meta.discourse.org/t/discourse-encodes-fragments-of-pasted-urls/137229/8 "2019-12-30T08:46:33Z")

</div>

这似乎已在 [DEV: Replace custom uri\_encode logic with Addressable by cvx · Pull Request #420 · discourse/onebox · GitHub](https://github.com/discourse/onebox/pull/420) 中修复。

我已将报告的 URL 添加到 `#uri_encode` 的测试用例中。

---

<div class="post-metadata">

### Author: ![jankeromnes](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jankeromnes/32/117299_2.png) [@jankeromnes](https://meta.discourse.org/u/jankeromnes)
#### Post date: [2020年二月13日 11:21 UTC](https://meta.discourse.org/t/discourse-encodes-fragments-of-pasted-urls/137229/9 "2020-02-13T11:21:31Z")

</div>

注意：在 Discourse 版本 `2.4.0.beta9 (c15d702ae6)` 中，此问题仍然存在：

在私信中，像 `https://gitpod.io/#snapshot/abcd-1234` 这样的 URL 仍会被错误地转换为 `https://gitpod.io/#snapshot%2Fabcd-1234`。

我注意到 Discourse `2.4.0.beta10` 现已发布——我可能会尝试升级，看看是否能解决问题。

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [2020年二月13日 12:05 UTC](https://meta.discourse.org/t/discourse-encodes-fragments-of-pasted-urls/137229/10 "2020-02-13T12:05:59Z")

</div>

我刚刚在私信里试了一下，成功了。

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [2020年二月15日 12:06 UTC](https://meta.discourse.org/t/discourse-encodes-fragments-of-pasted-urls/137229/11 "2020-02-15T12:06:07Z")

</div>

此主题在最后一次回复后 2 天自动关闭。不再允许新回复。
