kadirahq / flow-router

Carefully Designed Client Side Router for Meteor
MIT License
1.09k stars 194 forks source link

Prefixed paths (ROOT_URL) is not considered on IE9 hash position #496

Closed mperkh closed 8 years ago

mperkh commented 8 years ago

I have my app under example.com/myapp and ROOT_URL is set accordingly. When I open it under IE9, FR redirects to example.com/#/myapp, which makes it impossible to ever reach the app under IE9. It should be example.com/myapp/#.

Packages tomwasd:history-polyfill and tomwasd:flow-router-ie8 are installed

mquandalle commented 8 years ago

Any idea about this issue @arunoda?

arunoda commented 8 years ago

We won't support IE9 with the next version. So, I'm not sure about this.

mquandalle commented 8 years ago

Ok, I was not sure if this decision was already made or not.

BTW I wonder if this bug is pagejs responsibility as flow-router rely on it for both the base prefix and the IE9 #/ scheme. If someone is interested in that I guess we should try to reproduce the bug with vanilla pagejs and report the bug to them in case it is reproducible.

arunoda commented 8 years ago

I'm pretty much open to fix this since we support IE9 here, but not sure how to fix it. As you said, @mquandalle This could be the way how pagejs handling it. Hope we can do something.

mperkh commented 8 years ago

Happy to see, this problem gets adressed! Perhaps I am on the right track finding a fix. I installed the page.js examples and was able to get the 'basic' example running by

  1. adding http://github.com/jonathantneal/EventListener
  2. adding HTML History API Polyfill
  3. adding history.redirect('/','/basic/'); before page.base('/basic');

As mentioned here (https://github.com/visionmedia/page.js#support-in-ie8), the basepath for the HTML5-History-API polyfilI must be specified. I guess, the fix should be added to tomwasd:history-polyfill - have to try it, by fixing https://github.com/tomwasd/history-polyfill/blob/master/settings.js and configuring HTML5-History-API's basebath correctly by adding Meteor's basepath. Here my version of page.js's example (I have included the EventListener polyfill into history.min.js).

<!DOCTYPE html>
<html>
  <head>
    <title>Basic</title>
    <script type="text/javascript" src="/history.min.js"></script>
    <script src="/page.js"></script>
    <base href="/basic/" >
  </head>
  <body>
    <h1>Basic</h1>
    <p></p>
    <ul>
      <li><a href="./">/</a></li>
      <li><a href="#whoop">#whoop</a></li>
      <li><a href="./about">/about</a></li>
      <li><a href="./contact">/contact</a></li>
      <li><a href="./contact/me">/contact/me</a></li>
      <li><a href="./not-found?foo=bar">/not-found</a></li>
    </ul>

    <script>
      // the "notfound" implements a catch-all
      // with page('*', notfound). Here we have
      // no catch-all, so page.js will redirect
      // to the location of paths which do not
      // match any of the following routes
      //
      history.redirect('/','/basic/');
      page.base('/basic');

      page('/', index);
      page('/about', about);
      page('/contact', contact);
      page('/contact/:contactName', contact);
      page();

      function index() {
        document.querySelector('p')
          .textContent = 'viewing index';
      }

      function about() {
        document.querySelector('p')
          .textContent = 'viewing about';
      }

      function contact(ctx) {
        document.querySelector('p')
          .textContent = 'viewing contact ' + (ctx.params.contactName || '');
      }
    </script>
  </body>
</html>
mquandalle commented 8 years ago

Good to see that you are on the right track, your plan sounds good to me. Just in case you haven’t see it yet, this is how we get the basepath from Meteor in Flow-Router: https://github.com/kadirahq/flow-router/blob/88874ce49dc74378e4bbdecb95d1ed44c243e812/client/router.js#L38. So you could either copy paste this line in tomwasd:history-polyfill or directly read the value from FlowRouter._basePath as you wish.

@arunoda Do you think they should be a public API in Flow-Router to access the current basepath?

arunoda commented 8 years ago

@mquandalle Yeah! I think it could be that's a good idea. It may helps use cases like this.

mperkh commented 8 years ago

Seems the issue can be closed, since its not a flow-router issue and it needs to be addressed at tomwasd/history-polyfill. Hope @tomwasd is still maintaining the package.