Skip to content

Commit

Permalink
feat: 처음과 끝의 대괄호를 자동으로 없앤다
Browse files Browse the repository at this point in the history
  • Loading branch information
devxb committed Apr 15, 2024
1 parent 82240af commit 253a717
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class AnimationController(
response: HttpServletResponse
): String {
response.cacheControl(3600)
return animationFacade.getFarmAnimation(username)
return animationFacade.getFarmAnimation(deleteBrackets(username))
}

@GetMapping(value = ["/lines/{username}"], produces = ["image/svg+xml"])
Expand All @@ -29,7 +29,21 @@ class AnimationController(
response: HttpServletResponse,
): String {
response.cacheControl(3600)
return animationFacade.getLineAnimation(username, personaId)
return animationFacade.getLineAnimation(deleteBrackets(username), personaId)
}

private fun deleteBrackets(username: String): String {
val start = when (username[0]) {
'{' -> 1
else -> 0
}

val end = when (username.last()) {
'}' -> username.length - 1
else -> username.length
}

return username.substring(start, end)
}

fun HttpServletResponse.cacheControl(maxAgeSeconds: Int): HttpServletResponse {
Expand Down

0 comments on commit 253a717

Please sign in to comment.