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

我对 Client.buildUrl() 的内这段代码有点疑问 #5

Open
wangzishi opened this issue May 23, 2017 · 3 comments
Open

我对 Client.buildUrl() 的内这段代码有点疑问 #5

wangzishi opened this issue May 23, 2017 · 3 comments

Comments

@wangzishi
Copy link
Contributor

wangzishi commented May 23, 2017

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

if 判断的 condition 为什么要这么写呢?
什么情况下会是 toStringify[key]true,而 '' + toStringify[key]false 呢?
https://github.com/aliyun/api-gateway-nodejs-sdk/blob/master/lib/client.js#L106

@JacksonTian
Copy link
Contributor

欢迎发 PR,这个地方应该是参考了其他 SDK 不小心引入的坏味道。

@yuanchenxi95
Copy link

当toStringfy[key] = ‘’时

@yuanchenxi95
Copy link

我觉得在check是不是空string的时候,explicit check会比较好

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

3 participants