Skip to content

Commit fd0da6c

Browse files
tniessenRafaelGSS
authored andcommitted
src: avoid strcmp in ImportJWKAsymmetricKey
Use std::string_view and its operator== instead of calling strcmp on a const char*. PR-URL: #53813 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent 04d203a commit fd0da6c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/crypto/crypto_keys.cc

+5-4
Original file line numberDiff line numberDiff line change
@@ -509,16 +509,17 @@ Maybe<void> ExportJWKAsymmetricKey(Environment* env,
509509
std::shared_ptr<KeyObjectData> ImportJWKAsymmetricKey(
510510
Environment* env,
511511
Local<Object> jwk,
512-
const char* kty,
512+
std::string_view kty,
513513
const FunctionCallbackInfo<Value>& args,
514514
unsigned int offset) {
515-
if (strcmp(kty, "RSA") == 0) {
515+
if (kty == "RSA") {
516516
return ImportJWKRsaKey(env, jwk, args, offset);
517-
} else if (strcmp(kty, "EC") == 0) {
517+
} else if (kty == "EC") {
518518
return ImportJWKEcKey(env, jwk, args, offset);
519519
}
520520

521-
THROW_ERR_CRYPTO_INVALID_JWK(env, "%s is not a supported JWK key type", kty);
521+
THROW_ERR_CRYPTO_INVALID_JWK(
522+
env, "%s is not a supported JWK key type", kty.data());
522523
return std::shared_ptr<KeyObjectData>();
523524
}
524525

0 commit comments

Comments
 (0)