Left clicking link to /posts.rss does not work

AI-generated summary

Left clicking link to /posts.rss does not work

User ryantm reported an issue where left-clicking the link to /posts.rss results in a “page not found” error, but middle-clicking or copying the URL works fine. riking identified the problem as Ember Router assuming URLs not defined in the router as 404s.

tibarra investigated the issue and proposed a solution, creating a whitelist checker to determine if the route is internal or not. The code snippet was shared, but zogstrip suggested creating a pull request (PR) for review instead of sharing random code.

tibarra created a PR, but it initially failed to pass through Travis. zogstrip advised to retry, and tibarra resubmitted the PR. The updated PR can be found here. The issue also affects other links, such as /c/bug.rss, as reported by ryantm.

Left clicking this link does not work for me (displays “Oops! That page doesn’t exist or is private.”), but middle clicking it or copying the URL works fine:

link to posts rss

I am using Chrome Version 49.0.2623.87 m on Windows 10.

4개의 좋아요

This is the problem where URLs not defined in the Ember Router are assumed to be 404s.

5개의 좋아요

I’ll check this. Give me a moment please.

I think i found the solution, but it was a little tricky to do it, the route is not being sent to the server, i made a whitelist checker to know if the route is internal or not, can you review this @zogstrip @codinghorror @sam? I can make a PR if you want to, this works actually.

  isInternalPathButNotEmber: function(path){
    return path.indexOf("posts.rss") >= 0
  },

  routeTo(path, opts) {
    if (Em.isEmpty(path)) { return; }

    if (Discourse.get('requiresRefresh') || this.isInternalPathButNotEmber(path)) {
      document.location.href = Discourse.getURL(path);
      return;
    }

The same problem happens for categories:

https://meta.discourse.org/c/bug.rss

Yes this is a rare bug, because the routes exists so, the problem is when the POST is sent to the server, is rejected and misinterpreted as a 404 error, but is not passing through Ember i think.

It’s hard for us to review some random code. It’s better if you do the PR and then we review :wink:

I made a PR actually but i closed it because it didn’t pass through travis, i make it again anyways?

Sure, don’t trust travis. Unless everything is red.

3개의 좋아요

There you go :grin:

https://github.com/discourse/discourse/pull/4109

I made a groundwork for this, here is the PR updated:

https://github.com/discourse/discourse/pull/4109