Skip to content

Commit

Permalink
#1041 fix encoding of entity ids in REST URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardBradley committed May 24, 2016
1 parent 1d5bb9e commit 7153f73
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion doc/reference/Entity.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ Defines the base API endpoint for all views of this entity
Defines the API endpoint for all views of this entity. It can be a string or a function.

var comment = nga.entity('comments').url(function(entityName, viewType, identifierValue, identifierName) {
return '/comments/' + entityName + '_' + viewType + '?' + identifierName + '=' + identifierValue; // Can be absolute or relative
var e = encodeURIComponent;
return '/comments/' + e(entityName) + '_' + e(viewType) + '?' + e(identifierName) + '=' + e(identifierValue); // Can be absolute or relative
});

* `createMethod(string)` and `updateMethod(string)`
Expand Down
2 changes: 1 addition & 1 deletion doc/reference/View.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Disable this view. Useful e.g. to disable views that modify data and only leave
Defines the API endpoint for a view. It can be a string or a function.

comment.listView().url(function(entityId) {
return '/comments/id/' + entityId; // Can be absolute or relative
return '/comments/id/' + encodeURIComponent(entityId); // Can be absolute or relative
});

## listView Settings
Expand Down

0 comments on commit 7153f73

Please sign in to comment.