mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
src: avoid strcmp in ImportJWKAsymmetricKey
Use std::string_view and its operator== instead of calling strcmp on a const char*. PR-URL: https://github.com/nodejs/node/pull/53813 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
This commit is contained in:
1 parent
85fded51df
commit
7022e69b2e
1 file changed
+5
-4
@@ -509,16 +509,17 @@ Maybe<void> ExportJWKAsymmetricKey(Environment* env,
|
||||
std::shared_ptr<KeyObjectData> ImportJWKAsymmetricKey(
|
||||
Environment* env,
|
||||
Local<Object> jwk,
|
||||
const char* kty,
|
||||
std::string_view kty,
|
||||
const FunctionCallbackInfo<Value>& args,
|
||||
unsigned int offset) {
|
||||
if (strcmp(kty, "RSA") == 0) {
|
||||
if (kty == "RSA") {
|
||||
return ImportJWKRsaKey(env, jwk, args, offset);
|
||||
} else if (strcmp(kty, "EC") == 0) {
|
||||
} else if (kty == "EC") {
|
||||
return ImportJWKEcKey(env, jwk, args, offset);
|
||||
}
|
||||
|
||||
THROW_ERR_CRYPTO_INVALID_JWK(env, "%s is not a supported JWK key type", kty);
|
||||
THROW_ERR_CRYPTO_INVALID_JWK(
|
||||
env, "%s is not a supported JWK key type", kty.data());
|
||||
return std::shared_ptr<KeyObjectData>();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user