Skip to content

Commit

Permalink
add root path '/' for valid path
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiang Haiting committed Nov 9, 2021
1 parent 38f623b commit 0528c16
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,11 @@ protected static String parent(String path) {
* valid path in metadata store should be
* 1. not blank
* 2. starts with '/'
* 3. not ends with '/', (excludes single "/")
* 3. not ends with '/', except root path "/"
*/
public static boolean isValidPath(String path) {
return StringUtils.isNotBlank(path)
return StringUtils.equals(path, "/")
|| StringUtils.isNotBlank(path)
&& path.startsWith("/")
&& !path.endsWith("/");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void testPathValid() {
assertFalse(AbstractMetadataStore.isValidPath(null));
assertFalse(AbstractMetadataStore.isValidPath(""));
assertFalse(AbstractMetadataStore.isValidPath(" "));
assertFalse(AbstractMetadataStore.isValidPath("/"));
assertTrue(AbstractMetadataStore.isValidPath("/"));
assertTrue(AbstractMetadataStore.isValidPath("/test"));
assertFalse(AbstractMetadataStore.isValidPath("/test/"));
assertTrue(AbstractMetadataStore.isValidPath("/test/ABC"));
Expand Down

0 comments on commit 0528c16

Please sign in to comment.