Skip to content

Commit

Permalink
Ensure that the path always starts with /
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheikah45 committed Oct 14, 2023
1 parent 2c55731 commit a5ec937
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class CloudflareService {
mac.init(SecretKeySpec(secret.toByteArray(StandardCharsets.UTF_8), HMAC_SHA256))

val timeStamp = Instant.now().epochSecond
val macMessage = (uri.getPath() + timeStamp).toByteArray(StandardCharsets.UTF_8)
val path = if (uri.path.startsWith("/")) uri.path else "/" + uri.path
val macMessage = (path + timeStamp).toByteArray(StandardCharsets.UTF_8)
val hmacEncoded = URLEncoder.encode(
String(Base64.getEncoder().encode(mac.doFinal(macMessage)), StandardCharsets.UTF_8),
StandardCharsets.UTF_8,
Expand Down

0 comments on commit a5ec937

Please sign in to comment.