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:
Tobias Nießen authored and GitHub committed 2024-07-21 22:23:45 +00:00
1 parent 85fded51df
commit 7022e69b2e
1 file changed
+5 -4
+5 -4
View File
@@ -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>();
}