-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
40e1ea4
commit 8a5c783
Showing
8 changed files
with
33 additions
and
15 deletions.
There are no files selected for viewing
19 changes: 16 additions & 3 deletions
19
tracedin-domain/src/main/java/com/univ/tracedin/domain/project/EndPointUrl.java
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,16 +1,29 @@ | ||
package com.univ.tracedin.domain.project; | ||
|
||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
public record EndPointUrl(String value) { | ||
|
||
private static final Pattern ENDPOINT_PATTERN = | ||
Pattern.compile("^(https?://)([a-zA-Z0-9.-]+)(:[0-9]+)?(/[a-zA-Z0-9._-]+)*$"); | ||
Pattern.compile("^(?:https?://)?(?:[a-zA-Z0-9.-]+)(?::[0-9]+)?(/.*)"); | ||
|
||
public static EndPointUrl from(String url) { | ||
if (url == null || !ENDPOINT_PATTERN.matcher(url).matches()) { | ||
if (url == null || !isValidUrl(url)) { | ||
throw new IllegalArgumentException("Invalid endpoint URL format: " + url); | ||
} | ||
return new EndPointUrl(url); | ||
return new EndPointUrl(extractEndpoint(url)); | ||
} | ||
|
||
private static boolean isValidUrl(String url) { | ||
return ENDPOINT_PATTERN.matcher(url).find(); | ||
} | ||
|
||
private static String extractEndpoint(String url) { | ||
final Matcher matcher = ENDPOINT_PATTERN.matcher(url); | ||
if (matcher.find()) { | ||
return matcher.group(1); | ||
} | ||
throw new IllegalArgumentException("Unable to extract endpoint from URL: " + url); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
tracedin-domain/src/main/java/com/univ/tracedin/domain/project/ProjectAnalyzer.java
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,11 +1,11 @@ | ||
package com.univ.tracedin.domain.project; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public interface ProjectAnalyzer { | ||
|
||
ProjectStatistic<?> analyze( | ||
TraceSearchCondition cond, ProjectStatistic.StatisticsType statisticsType); | ||
|
||
List<EndPointUrl> getEndpoints(ServiceSearchCondition cond); | ||
Set<EndPointUrl> getEndpoints(ServiceSearchCondition cond); | ||
} |
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
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