Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可能吗?我正在使用 vibe.d 构建一个 REST Api 并实现令牌身份验证。因为我不知道用户将在哪种情况下向我发送 Authorization 标头参数,所以我需要以不区分大小写的方式查询它。例如:
string[string] foo; foo["XXX"] = "YYY"; logInfo(*("xxx" in foo)); // BOOM. Exception here
可能吗..?
谢谢
在存储或查询它们之前,只需将关联数组的所有键小写即可。
如果情况是全部较低或全部较高,那么您可能会有类似的东西
"xxx" in foo && logInfo(foo["xxx"]); "XXX" in foo && logInfo(foo["XXX"]);
也许有更有效的方法来做到这一点。如果您无法控制在 AA 中输入密钥的方式,那么在查询特定密钥时似乎必须检查所有大小写变体。