-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #181 from mash-up-kr/fix/url-parsing
fix: URL 파싱 정규식 추가, URL 검증 로직 추가
- Loading branch information
Showing
6 changed files
with
143 additions
and
100 deletions.
There are no files selected for viewing
24 changes: 20 additions & 4 deletions
24
.../main/kotlin/com/piikii/application/port/input/dto/request/PlaceAutoCompleteUrlRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,26 @@ | ||
package com.piikii.application.port.input.dto.request | ||
|
||
import com.piikii.common.exception.ExceptionCode | ||
import com.piikii.common.exception.PiikiiException | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
import jakarta.validation.constraints.NotNull | ||
import jakarta.validation.constraints.NotBlank | ||
import java.net.URI | ||
|
||
data class PlaceAutoCompleteUrlRequest( | ||
@field:NotNull(message = "URL 입력은 필수 입니다.") | ||
@field:NotBlank(message = "URL 입력은 필수 입니다.") | ||
@field:Schema(description = "장소 자동완성을 위한 지도 URL", example = "https://test.com/1231421") | ||
val url: String, | ||
) | ||
var url: String, | ||
) { | ||
init { | ||
val validatedUrl = | ||
Regex(REGEX_PATTERN).find(url)?.value ?: throw PiikiiException( | ||
exceptionCode = ExceptionCode.ILLEGAL_ARGUMENT_EXCEPTION, | ||
detailMessage = "URL이 요청 형식에 맞지 않습니다. : $url", | ||
) | ||
url = URI(validatedUrl).toString() | ||
} | ||
|
||
companion object { | ||
private const val REGEX_PATTERN = "(https://\\S+)" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,5 +29,6 @@ data class LemonUrl( | |
data class Regex( | ||
val web: String, | ||
val mobileWeb: String, | ||
val mobileApp: String, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters