Skip to content

Commit

Permalink
feat: use utility@2 (#17)
Browse files Browse the repository at this point in the history
<!-- 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 -->
  • Loading branch information
fengmk2 authored May 8, 2024
1 parent 16a4cad commit 7e677ca
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [16, 18, 20]
node-version: [16, 18, 20, 22]
os: [ubuntu-latest]

steps:
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,3 @@ jobs:
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
with:
checkTest: false
52 changes: 26 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,6 @@
"name": "oss-client",
"version": "2.0.1",
"description": "Aliyun OSS(Object Storage Service) Node.js Client",
"typings": "./dist/esm/index.d.ts",
"files": [
"dist",
"src"
],
"type": "module",
"tshy": {
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts"
}
},
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.js"
}
}
},
"scripts": {
"lint": "eslint src test --ext .ts",
"test": "egg-bin test",
Expand Down Expand Up @@ -61,7 +36,7 @@
"oss-interface": "^1.3.0",
"stream-wormhole": "^2.0.0",
"urllib": "^3.19.2",
"utility": "^1.18.0",
"utility": "^2.1.0",
"xml2js": "^0.6.2"
},
"devDependencies": {
Expand All @@ -79,5 +54,30 @@
"tshy-after": "^1.0.0",
"typescript": "^5.2.2"
},
"typings": "./dist/esm/index.d.ts",
"files": [
"dist",
"src"
],
"type": "module",
"tshy": {
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts"
}
},
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.js"
}
}
},
"types": "./dist/commonjs/index.d.ts"
}
4 changes: 2 additions & 2 deletions src/OSSBaseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createHash } from 'node:crypto';
import { extname } from 'node:path';
import { sendToWormhole } from 'stream-wormhole';
import { parseStringPromise } from 'xml2js';
import utility from 'utility';
import { encodeURIComponent as safeEncodeURIComponent } from 'utility';
import mime from 'mime';
import {
HttpClient, RequestOptions, HttpClientResponse, IncomingHttpHeaders,
Expand Down Expand Up @@ -91,7 +91,7 @@ export abstract class OSSBaseClient {
* encodeURIComponent name except '/'
*/
protected escape(name: string) {
return utility.encodeURIComponent(name).replaceAll('%2F', '/');
return safeEncodeURIComponent(name).replaceAll('%2F', '/');
}

protected abstract getRequestEndpoint(): string;
Expand Down
4 changes: 2 additions & 2 deletions src/util/json2xml.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import utility from 'utility';
import { escape as escapeHTML } from 'utility';

export function json2xml(json: Record<string, any>, options?: { headers: boolean }) {
let xml = '';
Expand All @@ -19,7 +19,7 @@ export function json2xml(json: Record<string, any>, options?: { headers: boolean
xml += json2xml(value);
xml += `</${key}>`;
} else {
xml += `<${key}>${utility.escape(value.toString())}</${key}>`;
xml += `<${key}>${escapeHTML(value.toString())}</${key}>`;
}
}
return xml;
Expand Down

0 comments on commit 7e677ca

Please sign in to comment.