Skip to content

Commit ece9d5e

Browse files
authored
Merge pull request #23 from serpapi/fix-22-multibyte-char-corruption
Handle HTTP chunking across multi-byte boundaries
2 parents 1cdcf24 + d9385fc commit ece9d5e

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

.github/workflows/build.yml

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Build
22

3-
on: [push, pull_request]
3+
on: [push]
44

55
jobs:
66
build:
@@ -52,6 +52,15 @@ jobs:
5252
strategy:
5353
matrix:
5454
node-version: [7.x, 8.x, 9.x, 10.x, 11.x, 12.x, 13.x, 14.x, 15.x, 16.x, 17.x, 18.x, 19.x]
55+
include:
56+
- command: test
57+
- command: test:use-openssl-ca
58+
node-version: 7.x
59+
- command: test:use-openssl-ca
60+
node-version: 8.x
61+
- command: test:use-openssl-ca
62+
node-version: 9.x
63+
5564
steps:
5665
- name: Checkout repo
5766
uses: actions/checkout@v3
@@ -76,7 +85,7 @@ jobs:
7685
run: |
7786
cd smoke_tests/commonjs
7887
npm i
79-
npm test
88+
npm run ${{ matrix.command }}
8089
8190
smoke-tests-esm:
8291
name: "Smoke tests (ESM)"

README.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ more.
1818
### Node.js
1919

2020
- Supports Node.js 7.10.1 and newer.
21-
- Refer to [this example](https://github.com/serpapi/serpapi-javascript/tree/master/examples/node/js_node_7_up) for help.
21+
- Refer to
22+
[this example](https://github.com/serpapi/serpapi-javascript/tree/master/examples/node/js_node_7_up)
23+
for help.
2224

2325
```bash
2426
npm install serpapi
@@ -40,7 +42,9 @@ getJson({
4042

4143
- If you prefer using the `import` syntax and top-level `await`, you need to use
4244
at least Node.js 14.8.0.
43-
- Refer to [this example](https://github.com/serpapi/serpapi-javascript/tree/master/examples/node/js_node_14_up) for help.
45+
- Refer to
46+
[this example](https://github.com/serpapi/serpapi-javascript/tree/master/examples/node/js_node_14_up)
47+
for help.
4448

4549
You will need to add `"type": "module"` to your `package.json`:
4650

@@ -66,7 +70,9 @@ console.log(response);
6670

6771
- Import directly from deno.land.
6872
- Usage is otherwise the same as above.
69-
- Refer to [this example](https://github.com/serpapi/serpapi-javascript/tree/master/examples/deno) for help.
73+
- Refer to
74+
[this example](https://github.com/serpapi/serpapi-javascript/tree/master/examples/deno)
75+
for help.
7076

7177
```ts
7278
import { getJson } from "https://deno.land/x/serpapi/mod.ts";

smoke_tests/commonjs/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"serpapi": "../../npm"
55
},
66
"scripts": {
7-
"test": "node commonjs.js"
7+
"test": "node commonjs.js",
8+
"test:use-openssl-ca": "node --use-openssl-ca commonjs.js"
89
}
910
}

src/utils.ts

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export function execute(
6363
return new Promise((resolve, reject) => {
6464
let timer: number;
6565
const req = https.get(url, (resp) => {
66+
resp.setEncoding("utf8");
6667
let data = "";
6768

6869
// A chunk of data has been recieved.

0 commit comments

Comments
 (0)