From f2fc70436a132a7b394db51ba7321fda77549321 Mon Sep 17 00:00:00 2001 From: saqqdy Date: Fri, 9 Aug 2024 15:54:07 +0800 Subject: [PATCH] fix: spliceUrlParam remove encodeURIComponent --- CHANGELOG.md | 4 ++++ README.md | 6 ++++-- package.json | 2 +- src/spliceUrlParam.ts | 8 +++----- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0ac41d1..473317b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change logs +## 2024.08.09 v5.20.0 + +1. `spliceUrlParam` Breaking change: remove encodeURIComponent + ## 2024.05.30 v5.19.2 1. upgrade `await-to-done`, fix types diff --git a/README.md b/README.md index 2d78f59d..7219d641 100644 --- a/README.md +++ b/README.md @@ -1533,6 +1533,8 @@ declare function parseUrlParam(url: string, covert?: boolean): Record v5.20.0 Breaking change: remove encodeURIComponent + - Since: `5.3.0` - Arguments: @@ -1548,8 +1550,8 @@ Splice URL parameters (single layer only) - Example: ```ts -spliceUrlParam({ key1: '100', key2: 'true', key3: 'null', key4: 'undefined', key4: '测试' }) -// ?key1=100&key2=true&key3=null&key4=undefined&key5=%E6%B5%8B%E8%AF%95 +spliceUrlParam({ key1: '100', key2: 'true', key3: 'null', key4: 'undefined', key5: '测试' }) +// ?key1=100&key2=true&key3=null&key4=undefined&key5=测试 spliceUrlParam({ key1: '100', key2: 'true', key3: 'null', key4: 'undefined' }, true) // ?key1=100&key2=true&key3=&key4= diff --git a/package.json b/package.json index b642afaa..2879ba43 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "js-cool", "description": "Collection of common JavaScript / TypeScript utilities", - "version": "5.19.2", + "version": "5.20.0", "packageManager": "pnpm@9.1.3", "main": "dist/index.cjs.js", "module": "dist/index.esm-bundler.js", diff --git a/src/spliceUrlParam.ts b/src/spliceUrlParam.ts index 5ad670e3..4f083847 100644 --- a/src/spliceUrlParam.ts +++ b/src/spliceUrlParam.ts @@ -3,8 +3,8 @@ * * @example * ```js - * spliceUrlParam('\{"key1":"100","key2":"true","key3":"null","key4":"undefined","key4":"测试"\}') - * // ?key1=100&key2=true&key3=null&key4=undefined&key5=%E6%B5%8B%E8%AF%95 + * spliceUrlParam('\{"key1":"100","key2":"true","key3":"null","key4":"undefined","key5":"测试"\}') + * // ?key1=100&key2=true&key3=null&key4=undefined&key5=测试 * * spliceUrlParam('\{"key1":"100","key2":"true","key3":"null","key4":"undefined"\}', true) * // ?key1=100&key2=true&key3=&key4= @@ -32,9 +32,7 @@ function spliceUrlParam>( const result: string[] = [] for (key in params) { typeof key === 'string' && - result.push( - `${key}=${encodeURIComponent('' + (covert ? params[key] ?? '' : params[key]))}` - ) + result.push(`${key}=${'' + (covert ? params[key] ?? '' : params[key])}`) } if (withQuestionsMark) return '?' + result.join('&')