Question

I'm trying to post a link to various articles from my website to Reddit, but they all of the same root URL, but are differentiated by using the hashbang (#) to go to different articles. I wrote my front end in with a single page application framework (Ember.js), which defaults to using hashbangs to designate different pages. Thus, here are some examples of different blog posts:

http://noobjs.org/#/posts/15

http://noobjs.org/#/posts/16

They are different pages and different articles, but Reddit tells me that the link was already submitted since it must not view the hashbang as significant. Does anyone know if there is a way around this? The answer may be that I change my site so that it no longer uses the hashbang, but I'd rather avoid that so I don't break any other links I sent out.

Any ideas?

Était-ce utile?

La solution

Reddit recognizes different query strings as being different pages. So, you can add a query string to the end that is the same as the hash.

http://noobjs.org/#/posts/15

http://noobjs.org/#/posts/16

become

http://noobjs.org/#/posts/15?/posts/15

http://noobjs.org/#/posts/16?/posts/16

It's not the prettiest, but it will work fine. Alternatively, you could write a check on page load against the URL to change ? into #.

window.location = window.location.href.replace("?", "#");

and post query string versions to reddit:

http://noobjs.org/?/posts/15

http://noobjs.org/?/posts/16

EDIT:

Currently, Ember does not have strong support for query parameters, but in this situation, a slight variation worked:

http://noobjs.org/?/#/posts/15

http://noobjs.org/?/#/posts/16

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top