-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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 #19501 from gsmet/fix-19492
Normalize the quarkus.http.root-path at config level
- Loading branch information
Showing
15 changed files
with
161 additions
and
56 deletions.
There are no files selected for viewing
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
40 changes: 40 additions & 0 deletions
40
...untime/src/main/java/io/quarkus/runtime/configuration/NormalizeRootHttpPathConverter.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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package io.quarkus.runtime.configuration; | ||
|
||
import static io.quarkus.runtime.configuration.ConverterSupport.DEFAULT_QUARKUS_CONVERTER_PRIORITY; | ||
|
||
import javax.annotation.Priority; | ||
|
||
import org.eclipse.microprofile.config.spi.Converter; | ||
|
||
/** | ||
* A converter to normalize paths that are considered root of something. | ||
* <p> | ||
* Any path coming out of this converter will have a leading and ending '/'. | ||
* <p> | ||
* Do NOT use this converter for paths that could be relative. | ||
*/ | ||
@Priority(DEFAULT_QUARKUS_CONVERTER_PRIORITY) | ||
public class NormalizeRootHttpPathConverter implements Converter<String> { | ||
|
||
private static final String SLASH = "/"; | ||
|
||
@Override | ||
public String convert(String value) throws IllegalArgumentException, NullPointerException { | ||
if (value == null) { | ||
return SLASH; | ||
} | ||
|
||
value = value.trim(); | ||
if (SLASH.equals(value)) { | ||
return value; | ||
} | ||
if (!value.startsWith(SLASH)) { | ||
value = SLASH + value; | ||
} | ||
if (!value.endsWith(SLASH)) { | ||
value = value + SLASH; | ||
} | ||
|
||
return value; | ||
} | ||
} |
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
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
Oops, something went wrong.