EmberJS router, dynamic segments, and percent-encoded forward-slash


#1

I’ve been trying to use a slash character as a segment of a dynamic route, but EmberJs doesn’t like that. I’ve tried using %2F instead, as that should be considered an escaped slash, but EmberJs is already recognizing that as a slash as well (and throwing “unrecognized route” type errors). I’m not sure if that’s intended… given that %2F is supposed to be an “escaped” forward slash, it doesn’t seem like it’s the sort of thing it should be doing, unless there’s a really good reason for it.

Could somebody with more detailed experience please provide additional information about this scenario?


#2

Hey @dgbonomo, I put a bounty on my question on Stackoverflow and I got an aswer http://stackoverflow.com/questions/18960472/how-to-handle-search-queries-that-contain-in-ember-js-apps/19023338?noredirect=1#19023338

Can you please try it and let me know if it works?


#3

Hi @tarasm. I actually did try that before I posted. It doesn’t seem to work, presumably because the special characters seem to be decoded by what I guess is Ember itself (but I’m not 100% sure if that’s accurate). You can try this by typing a %2F in the URL on your own as well, the %2F is automatically changed into a forward slash (trying it on any old static page will show you that this doesn’t normally happen on its own).


#4

He seems confident that this is the solution. I’m going to try it myself as soon as I get a chance to.


#5

It would be better if we had a “:everything_past_this_point” type dynamic segment, perhaps then Ember wouldn’t be as confused, but I’m not sure if that exists or is doable, or whether all the above is a bug to begin with. I’d still appreciate your retesting the suggestion in case I missed something; but at the moment the solution seems to be “do not use forward slashes”. Even if %2F was usable, it wouldn’t be very readable - people would have a hard time figuring out what the URL says, and an unnecessarily hard time adjusting it. Unless the “everything past this” is possible, it seems like it’s better to replace forward slashes with another easily readable character (backslash or dash). It’s less ideal and more involved from a technical code perspective, but at least it’s more acceptable in terms of usability.


#6

I’ll give it a look as soon as I get a chance.

But not using / does seem like a reasonable solution. Even converting date / to -