-
Notifications
You must be signed in to change notification settings - Fork 726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
String ID with non-URLsafe chars causes 404 when viewing detail page #1041
Comments
It's not an ng-admin issue, and it's the default behaviour of restangular and $http (mgonto/restangular#232) You need to safe url-encode your id first. Here an example : http://plnkr.co/edit/qrw9Y8rfUUmHM4rOJo1q?p=preview (the user John has 'test+/' as id. I just used a Restangular interceptor and encodeURIComponent the url. |
Yes, this is a bug in I think that In the meantime, I'll add that workaround to my app. Thanks for your help. |
Your workaround doesn't work; that plunker still sends invalid requests to the backend:
However, the "backend.js" has a broken URL parser which accepts these invalid URLs:
A similar example with a real REST backend doesn't work. |
I don't think this can be fixed with a request interceptor. In general, how could a request interceptor distinguish between a "get" request for a "foo" object with id "1/bar/2" or a "get" request for a "bar" object with id "2" which is a child of "foo" with id "1"? |
Indeed, your case can only work if you dont have two object to handle, eg with nodejs:
Will works. But as soon you have two entity to handle, it's not gonna works, eg:
I can't help you here, the only way to solve cleanly this problem is to either change the id generator used to avoid conflict or future edge-case, or use a correct encoder on each parameter. |
This isn't a Restangular bug; it's an
I'll look into submitting a PR, and I'll update those Restangular bugs |
Hmmm, if it's entityId, have you try to use the url hook which let you define the way you send ng-admin entityId ?
ps: You were right, my initial "workaround" was incorrect due to regex 'catcher', the full url was url-encoded, which was wrong. |
That would fix it, yes. As I'm already running a fork of |
#1041 fix encoding of entity ids in REST URLs
Fixed by #1088 |
This still doesn't work for me. However, the List view detail link for an entity with a non-URL-safe id is broken, as the link is escaped with "~" instead of "%". You can see this in the plunkr linked at the top of this thread: http://plnkr.co/edit/qrw9Y8rfUUmHM4rOJo1q?p=preview |
I have an entity with a string ID field.
If the ID contains non-URLsafe chars like "+" or "/" then the detail links from the list view correctly escapes these chars, i.e. https://my-app.example.com/#/users/edit/x5ig%2BnkzATc%252FCBz , however following that link does not work:
I believe this is because the REST GET request for the user does not correctly escape the ID when using it as a URL parameter:
The text was updated successfully, but these errors were encountered: