How are URLs encoded in Ember?


#1

Using Ember 2.13.2. If I have the following route:

this.route('foobar', { path: '/:id' });

And in routes/foobar.js I have:

model (params) {
  console.log(params);
}

When I hit /[@: I will get /%5B@: in the browser URL and id: "[@:" in the console. If I hit /%5B%40 I will get /%5B@ in the browser URL and id: "[@" in the console. The console.logs are correct, but I’m wondering about the browser URL. Why are some symbols encoded? Why are some symbols decoded? Why isn’t this consistent with encodeURIComponent which will actually encode all of these symbols ([, @ and :)? Is the function for encoding that is used internally exposed somewhere so I could use it for my own routes which have globbed dynamic segments in order to be consistent with Ember?


#2

Read please about http. Just read…


#3

Hopefully a more helpful answer is that you could try playing around with the route ‘serialize’ method and maybe look at the default serialize function in the ember route class. I’m not expert but that might get you on the right path, or at least let you override the behavior if you need it to work differently.