Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when the query value is 0 or false, the k-v item will miss #14

Open
jazzhuang opened this issue Oct 27, 2017 · 3 comments
Open

when the query value is 0 or false, the k-v item will miss #14

jazzhuang opened this issue Oct 27, 2017 · 3 comments

Comments

@jazzhuang
Copy link

if (toStringify[key] && ('' + toStringify[key])) {

注:
根据网关的文档签名描述,https://help.aliyun.com/document_detail/29475.html?spm=5176.product29462.6.569.ZDrfpw
“如果某个参数的 Value 为空只保留 Key 参与签名,等号不需要再加入签名。” 可能代码实现的时候误解了这里的意思了!

@JacksonTian
Copy link
Contributor

完成的实现并没有错:

        if (toStringify[key] && ('' + toStringify[key])) {
          list[i] = `${key}=${toStringify[key]}`;
        } else {
          list[i] = `${key}`;
        }

如果 0 或者 false,会转成字符串的形式,其长度不为 0.

@jazzhuang
Copy link
Author

jazzhuang commented Oct 30, 2017

如果是0或者false, toStringify[key] == false, 即 toStringify[key] && ('' + toStringify[key]) == false

@JacksonTian
Copy link
Contributor

我知道问题了。因为之前都是从 querystring 上取下来的值,都是 string 类型的。所以不存在 0/false 的情况。当POST的时候,才会命中这个逻辑。

@JacksonTian JacksonTian reopened this Oct 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants