# Oneboxing of sites with hash (#) in URL not working

**URL:** <https://meta.discourse.org/t/oneboxing-of-sites-with-hash-in-url-not-working/66804>\
**Category:** Bug\
**Created:** [2017 年 7 月 25 日午後 6:46 UTC](https://meta.discourse.org/t/oneboxing-of-sites-with-hash-in-url-not-working/66804 "2017-07-25T18:46:10Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)\
**Post date:** [2017 年 7 月 26 日午前 8:51 UTC](https://meta.discourse.org/t/oneboxing-of-sites-with-hash-in-url-not-working/66804/5 "2017-07-26T08:51:23Z")

</div>

Wow, this was a tricky issue to debug. This is not related to “prefer canonical URL” change.

Also, this issue is not specific to GitHub only, but all the sites that uses # magic. For example:

> **[OS X 10.10 Yosemite: The Ars Technica Review](https://arstechnica.com/gadgets/2014/10/os-x-10-10/#page-12)**
>
> For the first time in forever, the Mac could be noticed by someone.

This regression was introduced eleven days ago in [this commit](https://github.com/discourse/discourse/commit/b534778f46ac310d9b59afa6f5390fced267f2f0). Specifically in [this code](https://github.com/discourse/discourse/blob/b534778f46ac310d9b59afa6f5390fced267f2f0/lib/final_destination.rb#L15):

```plaintext
URI(URI.escape(url)) if url

```

Escaping the URL converts/encodes `#` in link to `%23` and some sites does not handle that well, GitHub and Ars Technica included.

Wikipedia handle this just well, for example:

```plaintext
https://en.wikipedia.org/wiki/Percent-encoding#Percent-encoding_reserved_characters

```

> **[Percent-encoding](https://en.wikipedia.org/wiki/Percent-encoding#Percent-encoding_reserved_characters)**
>
> Percent-encoding, also known as URL encoding, is a method to encode arbitrary data in a uniform resource identifier (URI) using only the US-ASCII characters legal within a URI. Percent-encoding is used to ensure special characters do not interfere with the URI's structure and interpretation. Special characters are replaced with a percent sign (%) followed by two hexadecimal digits representing the character's byte value. For example, a space is commonly encoded as %20:
> Although it is known as UR...

@eviltrout should we remove the URL escaping here? Or add a new case for sites with `404` response?

---

_[View the full topic](https://meta.discourse.org/t/oneboxing-of-sites-with-hash-in-url-not-working/66804)._
