0

I really need to have a period in either a parameter or a route but lite-server seems to object to this.

I have found several places referencing the issue and saying that it can be fixed with a rewrite rule but there are no complete examples that I can see that work.

For instance this answer: "dot" in query string parameter - AngularJS

The path that can have a dot in it is /report;url=example.com.

Based on above answer I editted bs-config.json to this:

{
  "server": {
    "baseDir": "src",
    "routes": {
      "/node_modules": "node_modules"
    },
    "rewrites": [
      {
        "from": "/^\/report/",
        "to": "index.html"
      }
    ]
  }
}

I also tried putting rewrites a level higher but neither had any effect on anything.

If I use navigate('report/', { url: 'value.with.dot' }) then I can use a period in the route or param and it works fine but I can't access it directly by typing in the url to browser.

I find lots of mentions on the internet about this being due to lite-server config but no straight forward example of what exactly to add to the lite-server config to fix it.

I am using Angular2.4 but i think this is problem specific to lite-server.

So essentially I need a rewrite rule to re-write the request to index.html but the way i have entered it has not worked.

Community
  • 1
  • 1
Guerrilla
  • 13,375
  • 31
  • 109
  • 210
  • How did you resolve this? I'm going through the same issue. Was it a config you plopped in at your project root to overwrite default lite-server settings? I basically want to accept the dot coming so it drops to my correct route. – markreyes May 13 '17 at 17:49
  • I switched to latest version of Angular CLI which seems to have a rewrite rule in it as default. – Guerrilla May 13 '17 at 22:54

2 Answers2

1

Maybe just shield the dot, like this "example\.com"?

Vitalii Andrusishyn
  • 3,984
  • 1
  • 25
  • 31
0

You should encapsulate inside a quotes

navigate('report/', { url: "'value.with.dot'" ))
Aravind
  • 40,391
  • 16
  • 91
  • 110
  • It works fine with navigate, I have no problems with navigate so I do not need to change anything with that. The problem I have is accessing the url directly. Lite server treats all paths with period as a file and other answers say that a rewrite rule must be made. – Guerrilla Mar 11 '17 at 19:58
  • you need to change in the route definitions also – Aravind Mar 11 '17 at 20:00
  • this is route definition `{ path: 'report', component: MyReportComponent }` Did you look at other answer I linked? I don't think you are understanding my problem. – Guerrilla Mar 11 '17 at 20:11
  • I want to be able to use a period (this ---> . <----this) in a path I type into browser. – Guerrilla Mar 11 '17 at 20:33