Skip to content

Commit 7e677ca

Browse files
authored
feat: use utility@2 (#17)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Chores** - Updated utility library version to enhance performance. - **Tests** - Expanded test coverage to include the latest Node.js version. - **Documentation** - Updated project description for clarity. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 16a4cad commit 7e677ca

File tree

5 files changed

+31
-33
lines changed

5 files changed

+31
-33
lines changed

.github/workflows/nodejs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
node-version: [16, 18, 20]
21+
node-version: [16, 18, 20, 22]
2222
os: [ubuntu-latest]
2323

2424
steps:

.github/workflows/release.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,3 @@ jobs:
1111
secrets:
1212
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
1313
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
14-
with:
15-
checkTest: false

package.json

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,6 @@
22
"name": "oss-client",
33
"version": "2.0.1",
44
"description": "Aliyun OSS(Object Storage Service) Node.js Client",
5-
"typings": "./dist/esm/index.d.ts",
6-
"files": [
7-
"dist",
8-
"src"
9-
],
10-
"type": "module",
11-
"tshy": {
12-
"exports": {
13-
"./package.json": "./package.json",
14-
".": "./src/index.ts"
15-
}
16-
},
17-
"exports": {
18-
"./package.json": "./package.json",
19-
".": {
20-
"import": {
21-
"types": "./dist/esm/index.d.ts",
22-
"default": "./dist/esm/index.js"
23-
},
24-
"require": {
25-
"types": "./dist/commonjs/index.d.ts",
26-
"default": "./dist/commonjs/index.js"
27-
}
28-
}
29-
},
305
"scripts": {
316
"lint": "eslint src test --ext .ts",
327
"test": "egg-bin test",
@@ -61,7 +36,7 @@
6136
"oss-interface": "^1.3.0",
6237
"stream-wormhole": "^2.0.0",
6338
"urllib": "^3.19.2",
64-
"utility": "^1.18.0",
39+
"utility": "^2.1.0",
6540
"xml2js": "^0.6.2"
6641
},
6742
"devDependencies": {
@@ -79,5 +54,30 @@
7954
"tshy-after": "^1.0.0",
8055
"typescript": "^5.2.2"
8156
},
57+
"typings": "./dist/esm/index.d.ts",
58+
"files": [
59+
"dist",
60+
"src"
61+
],
62+
"type": "module",
63+
"tshy": {
64+
"exports": {
65+
"./package.json": "./package.json",
66+
".": "./src/index.ts"
67+
}
68+
},
69+
"exports": {
70+
"./package.json": "./package.json",
71+
".": {
72+
"import": {
73+
"types": "./dist/esm/index.d.ts",
74+
"default": "./dist/esm/index.js"
75+
},
76+
"require": {
77+
"types": "./dist/commonjs/index.d.ts",
78+
"default": "./dist/commonjs/index.js"
79+
}
80+
}
81+
},
8282
"types": "./dist/commonjs/index.d.ts"
8383
}

src/OSSBaseClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { createHash } from 'node:crypto';
44
import { extname } from 'node:path';
55
import { sendToWormhole } from 'stream-wormhole';
66
import { parseStringPromise } from 'xml2js';
7-
import utility from 'utility';
7+
import { encodeURIComponent as safeEncodeURIComponent } from 'utility';
88
import mime from 'mime';
99
import {
1010
HttpClient, RequestOptions, HttpClientResponse, IncomingHttpHeaders,
@@ -91,7 +91,7 @@ export abstract class OSSBaseClient {
9191
* encodeURIComponent name except '/'
9292
*/
9393
protected escape(name: string) {
94-
return utility.encodeURIComponent(name).replaceAll('%2F', '/');
94+
return safeEncodeURIComponent(name).replaceAll('%2F', '/');
9595
}
9696

9797
protected abstract getRequestEndpoint(): string;

src/util/json2xml.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import utility from 'utility';
1+
import { escape as escapeHTML } from 'utility';
22

33
export function json2xml(json: Record<string, any>, options?: { headers: boolean }) {
44
let xml = '';
@@ -19,7 +19,7 @@ export function json2xml(json: Record<string, any>, options?: { headers: boolean
1919
xml += json2xml(value);
2020
xml += `</${key}>`;
2121
} else {
22-
xml += `<${key}>${utility.escape(value.toString())}</${key}>`;
22+
xml += `<${key}>${escapeHTML(value.toString())}</${key}>`;
2323
}
2424
}
2525
return xml;

0 commit comments

Comments
 (0)