kadirahq / flow-router

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

[flow-router-ssr][but/feature] SSR when dot in url #670

Open TimoRuetten opened 8 years ago

TimoRuetten commented 8 years ago

I am wondering if there is a way that the SSR is also working when a dot is inside the url.

Example:

url.com/users/timo.ruetten

This url will not rendered on server the DOM.

url.com/users/timo-ruetten will be rendered on server instead.

Is there any way to make sure that a url with a dot will also be rendered on server ?

TimoRuetten commented 8 years ago

I have fixed it now for me.

In server/route there is this method:

  _isHtmlPage(url) {
    const pathname = Url.parse(url).pathname;
    const ext = pathname.split('.').slice(1).join('.');

    // if there is no extention, yes that's a html page
    if (!ext) {
      return true;
    }

    // if this is htm or html, yes that's a html page
    if (/^htm/.test(ext)) {
      return true;
    }

    // if not we assume this is not as a html page
    // this doesn't do any harm. But no SSR
    return false;
  }

So everytime when its not .html or .html but with dot in url no SSR is given. This is very bad in my case. In my case I changed the code to check if its a typical file of my app like images and documents and if not returning true. In my case of app its important to render also urls with dots in it on SSR.

It would be nice to improve this method so its more easy to have control if a URL has to be rendered on Server.