Skip to content

Commit 6a50dc5

Browse files
fixed/remotefilter-encode-value auto-commit (#361)
1 parent 3f3ca24 commit 6a50dc5

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## [Unreleased]
88

9+
## [3.0.2] - 2023-01-20
10+
11+
## Fixed
12+
13+
- Fixed when filtering with an operator, object is added as a value ([#361](https://github.com/reyesoft/ngx-jsonapi/pull/361))
14+
915
## [3.0.0] - 2021-12-23
1016

1117
## Changed

src/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ngx-jsonapi",
3-
"version": "3.0.0",
3+
"version": "3.0.2",
44
"description": "JSON API library for Angular",
55
"module": "ngx-jsonapi/@ngx-jsonapi/ngx-jsonapi.es5.js",
66
"es2015": "ngx-jsonapi/@ngx-jsonapi/ngx-jsonapi.js",

src/services/path-collection-builder.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ describe('Path Builder', () => {
5858
expect(path_collection_builder.get().includes('filter[field]=foo%26bar')).toBeTruthy();
5959
});
6060

61+
it('if filter with operator (ne) they should be formatted and included in get_params', () => {
62+
path_collection_builder.applyParams(testService, { remotefilter: { status: { ne: 'archived' } } });
63+
expect(path_collection_builder.get().includes('filter[status][ne]=archived')).toBeTruthy();
64+
});
65+
6166
it('if page params are provided, applyParams should call addParam one or two times with the page number and size', () => {
6267
Core.me.injectedServices.rsJsonapiConfig.parameters.page.number = 'page_index';
6368
Core.me.injectedServices.rsJsonapiConfig.parameters.page.size = 'page_size';

src/services/url-params-builder.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ export class UrlParamsBuilder {
1414
let ret = '';
1515
if (Array.isArray(params) || params instanceof Object) {
1616
Base.forEach(params, (value, key) => {
17-
ret += this.toparamsarray(encodeURIComponent(value), add + '[' + key + ']');
17+
let valueEncodeOrNot = value instanceof Object ? value : encodeURIComponent(value);
18+
ret += this.toparamsarray(valueEncodeOrNot, add + '[' + key + ']');
1819
});
1920
} else {
2021
ret += add + '=' + params;

0 commit comments

Comments
 (0)