You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by hu...@apache.org on 2021/08/03 06:29:29 UTC
[dubbo-js] branch master updated: fixed:consumer url unnecessary
escape && and querystring test
This is an automated email from the ASF dual-hosted git repository.
hufeng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-js.git
The following commit(s) were added to refs/heads/master by this push:
new a7694f9 fixed:consumer url unnecessary escape && and querystring test
a7694f9 is described below
commit a7694f96d6c31765314820ec8c27a39df5ec5965
Author: hufeng <fe...@gmail.com>
AuthorDate: Tue Aug 3 12:07:01 2021 +0800
fixed:consumer url unnecessary escape && and querystring test
---
packages/dubbo-service/src/__tests__/qs-test.ts | 38 +++++++++++++++++++++++++
packages/dubbo-service/src/dubbo-service.ts | 9 ++++--
2 files changed, 44 insertions(+), 3 deletions(-)
diff --git a/packages/dubbo-service/src/__tests__/qs-test.ts b/packages/dubbo-service/src/__tests__/qs-test.ts
new file mode 100644
index 0000000..9ea6e17
--- /dev/null
+++ b/packages/dubbo-service/src/__tests__/qs-test.ts
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import qs from 'querystring'
+
+describe('qs test suite', () => {
+ it('test without default encoder', () => {
+ const str = qs.stringify(
+ {
+ application: 'test',
+ group: '',
+ version: '0.0.0',
+ methods: 'sayHello,sayWorld'
+ },
+ null,
+ null,
+ { encodeURIComponent: (str) => str }
+ )
+
+ expect(str).toEqual(
+ 'application=test&group=&version=0.0.0&methods=sayHello,sayWorld'
+ )
+ })
+})
diff --git a/packages/dubbo-service/src/dubbo-service.ts b/packages/dubbo-service/src/dubbo-service.ts
index 9fcbb8a..cbbb93e 100644
--- a/packages/dubbo-service/src/dubbo-service.ts
+++ b/packages/dubbo-service/src/dubbo-service.ts
@@ -58,8 +58,8 @@ export default class DubboService {
private reject: Function
private readonly readyPromise: Promise<void>
- private application: { name: string }
- private dubbo: string
+ private readonly application: { name: string }
+ private readonly dubbo: string
private retry: Retry
private port: number
@@ -319,7 +319,10 @@ export default class DubboService {
params['version'] = version
}
return (
- `dubbo://${ipAddr}:${this.port}/${dubboInterface}?` + qs.stringify(params)
+ `dubbo://${ipAddr}:${this.port}/${dubboInterface}?` +
+ qs.stringify(params, null, null, {
+ encodeURIComponent: (str) => str
+ })
)
}