# Intra-post anchor links don't work in Safari / Firefox

**URL:** https://meta.discourse.org/t/intra-post-anchor-links-dont-work-in-safari-firefox/29125
**Category:** Bug
**Tags:** ember
**Created:** [5월 22, 2015, 1:19오후 UTC](https://meta.discourse.org/t/intra-post-anchor-links-dont-work-in-safari-firefox/29125 "2015-05-22T13:19:17Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![plkap74](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/plkap74/32/116106_2.png) [@plkap74](https://meta.discourse.org/u/plkap74)
#### Post date: [5월 22, 2015, 1:19오후 UTC](https://meta.discourse.org/t/intra-post-anchor-links-dont-work-in-safari-firefox/29125/1 "2015-05-22T13:19:17Z")

</div>

I’ve been experimenting with anchor links inside of posts (links to content inside of a long post). I have read that you can’t use the `id`s because they get stripped. I used the `name` property instead and it works for Chrome but throws a very cryptic error in Safari.

```plaintext
Error: Syntax error, unrecognized expression: [name=anchor-name

```

It doesn’t give a useful trace so I can’t even tell where it is coming from. Is the anchor routing dealt with by Ember? Is there custom logic for that somewhere?

* * *

## Example 1 (Live bug)

Try going to this link in Chrome (it works) but in Safari it throws an error and doesn’t work:

> **[Guidelines - Discourse Demo](https://try.discourse.org/guidelines)**
>
> Demonstration sandbox for Discourse

* * *

## Example 2 (Reproduced bug)

works in Chrome, throws errors in safari

### Table of contents

- [Topic 1](#topic-1)
- [Topic 2](#topic-2)
- [TOC markup](#toc-markup)

#### Topic 1

The markup for this heading is:

```plaintext
#### <a name="topic-1">Topic 1</a>

```

#### Topic 2

The markup for this heading is:

```plaintext
#### <a name="topic-2">Topic 2</a>

```

#### TOC Markup

The markup for the table of contents is

```plaintext
### Table of contents
- <a href="#topic-1">Topic 1</a>
- <a href="#topic-2">Topic 2</a>
- <a href="#toc-markup">TOC markup</a>

```

---

<div class="post-metadata">

### Author: ![anon42064797](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@anon42064797](https://meta.discourse.org/u/anon42064797)
#### Post date: [5월 22, 2015, 8:34오후 UTC](https://meta.discourse.org/t/intra-post-anchor-links-dont-work-in-safari-firefox/29125/2 "2015-05-22T20:34:12Z")

</div>

I can repro this on Firefox v38

---

<div class="post-metadata">

### Author: ![plkap74](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/plkap74/32/116106_2.png) [@plkap74](https://meta.discourse.org/u/plkap74)
#### Post date: [5월 23, 2015, 1:54오후 UTC](https://meta.discourse.org/t/intra-post-anchor-links-dont-work-in-safari-firefox/29125/3 "2015-05-23T13:54:38Z")

</div>

Plot like gravy thickens. It appears to not throw any errors in development mode, only in production…

---

<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: [5월 24, 2015, 11:55오후 UTC](https://meta.discourse.org/t/intra-post-anchor-links-dont-work-in-safari-firefox/29125/4 "2015-05-24T23:55:56Z")

</div>

Can be minifier related , seen a minifier bug once before

---

<div class="post-metadata">

### Author: ![plkap74](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/plkap74/32/116106_2.png) [@plkap74](https://meta.discourse.org/u/plkap74)
#### Post date: [5월 25, 2015, 1:45오후 UTC](https://meta.discourse.org/t/intra-post-anchor-links-dont-work-in-safari-firefox/29125/5 "2015-05-25T13:45:21Z")

</div>

Can you point me to where in the JS this is being handled?

---

<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: [5월 25, 2015, 9:24오후 UTC](https://meta.discourse.org/t/intra-post-anchor-links-dont-work-in-safari-firefox/29125/6 "2015-05-25T21:24:23Z")

</div>

It is here

> <https://github.com/discourse/discourse/blob/main/lib/tasks/assets.rake#L98>

---

<div class="post-metadata">

### Author: ![plkap74](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/plkap74/32/116106_2.png) [@plkap74](https://meta.discourse.org/u/plkap74)
#### Post date: [5월 26, 2015, 12:44오후 UTC](https://meta.discourse.org/t/intra-post-anchor-links-dont-work-in-safari-firefox/29125/7 "2015-05-26T12:44:09Z")

</div>

I’m sorry I should have been more specific, I meant where was the name anchor code happening. I dove in and found it in `javascripts/discourse/lib/url.js`. It looks like there is a missing bracket.

> <https://github.com/discourse/discourse/blob/f496982e7952aa13e86853250bcf0505a216f94f/app/assets/javascripts/discourse/lib/url.js#L92>

Not sure why that would break only production though…

I’ll submit a PR.

---

<div class="post-metadata">

### Author: ![plkap74](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/plkap74/32/116106_2.png) [@plkap74](https://meta.discourse.org/u/plkap74)
#### Post date: [5월 26, 2015, 12:53오후 UTC](https://meta.discourse.org/t/intra-post-anchor-links-dont-work-in-safari-firefox/29125/8 "2015-05-26T12:53:27Z")

</div>

PR submitted

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

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [5월 26, 2015, 1:53오후 UTC](https://meta.discourse.org/t/intra-post-anchor-links-dont-work-in-safari-firefox/29125/9 "2015-05-26T13:53:17Z")

</div>


