Skip to content

Commit 81b0628

Browse files
authored
Merge pull request #63 from apisearch-io/fix/fixed-special-hash-character-in-search
Fixed hash character in url parameters
2 parents 19bdd84 + 9a9c1be commit 81b0628

File tree

5 files changed

+32
-10
lines changed

5 files changed

+32
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "apisearch",
3-
"version": "0.2.30",
3+
"version": "0.2.31",
44
"description": "Javascript client for Apisearch.",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",

src/Http/AxiosClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export class AxiosClient extends Client implements HttpClient {
8787
...{
8888
token: credentials.token,
8989
},
90-
}),
90+
}).replace(/#/g, '%23'),
9191
};
9292

9393
if (typeof this.cancelToken[url] !== "undefined") {

test/Functional/Apisearch/Error.test.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ import Axios from "axios";
22
import {expect} from "chai";
33
import * as sinon from "sinon";
44
import Apisearch from "../../../src/Apisearch";
5-
import {Config} from "../../../src/Config/Config";
6-
import {ConnectionError} from "../../../src/Error/ConnectionError";
7-
import {InvalidTokenError} from "../../../src/Error/InvalidTokenError";
8-
import {ResourceExistsError} from "../../../src/Error/ResourceExistsError";
9-
import {ResourceNotAvailableError} from "../../../src/Error/ResourceNotAvailableError";
105
import {UnknownError} from "../../../src/Error/UnknownError";
116
import {IndexUUID} from "../../../src/Model/IndexUUID";
12-
import {Query} from "../../../src/Query/Query";
137
import FunctionalTest from "./FunctionalTest";
8+
import {
9+
Config,
10+
ConnectionError,
11+
InvalidTokenError,
12+
Query, ResourceExistsError,
13+
ResourceNotAvailableError
14+
} from "../../../src";
1415

1516
afterEach(() => {
1617
sinon.restore();

test/Functional/Apisearch/FunctionalTest.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Apisearch from "../../../src/Apisearch";
2-
import {HttpRepository} from "../../../src/Repository/HttpRepository";
2+
import {HttpRepository} from "../../../src";
33

44
/**
55
* Apisearch class
@@ -15,10 +15,10 @@ export default class FunctionalTest {
1515
return Apisearch.createRepository({
1616
app_id: "789437438test",
1717
index_id: "default",
18+
token: "0e4d75ba-c640-44c1-a745-06ee51db4e93",
1819
options: {
1920
endpoint: "http://localhost:8000",
2021
},
21-
token: "0e4d75ba-c640-44c1-a745-06ee51db4e93",
2222
});
2323
}
2424
}

test/Functional/Apisearch/Query.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,4 +227,25 @@ describe('Apisearch', () => {
227227
});
228228
});
229229

230+
231+
it('should be able to work with strange characters', async() => {
232+
const items = [
233+
Item.create(ItemUUID.createByComposedUUID('1~item'), {
234+
'name': "strange # character"
235+
}, {}, {
236+
'name': 'strange # character'
237+
}),
238+
];
239+
240+
repository.addItems(items);
241+
await repository.flush();
242+
243+
await repository
244+
.query(Query
245+
.create('strange # char')
246+
)
247+
.then(result => {
248+
expect(result.getFirstItem().getUUID().getId()).to.be.equal("1");
249+
});
250+
});
230251
});

0 commit comments

Comments
 (0)