-
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.
Normalize the quarkus.http.root-path and RESTEasy deployment path at …
…config level Make sure both paths always start and end with a '/' so that we don't have any risk of having logic working with '/test' and not with '/test/'. Also simplify a few things thanks to that. Fixes #19492
- Loading branch information
Showing
7 changed files
with
86 additions
and
24 deletions.
There are no files selected for viewing
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