deniskuzZ commented on PR #6749:
URL: https://github.com/apache/hive/pull/6749#issuecomment-5703194720
please check
````
@Test
public void testResourceNamedNamespacesIsNotTreatedAsPrefix() {
assertEquals(Route.LOAD_NAMESPACE,
route("v1/namespaces/namespaces").first());
assertEquals(Route.LOAD_TABLE,
route("v1/namespaces/db/tables/namespaces").first());
assertEquals(Route.UPDATE_TABLE,
Route.from(HTTPMethod.POST,
"v1/namespaces/db/tables/namespaces").first());
assertEquals(Route.LOAD_TABLE,
route("v1/catalogs/sales/namespaces/db/tables/namespaces").first());
}
````
I think an exact-length match (no prefix) should always win, and among
prefixed matches, the fewest prefix segments should win:
````
public static Pair<Route, Map<String, String>> from(HTTPMethod method,
String path) {
List<String> parts = SLASH.splitToList(path);
Route best = null;
for (Route candidate : Route.values()) {
if (candidate.matches(method, parts)
&& (best == null || candidate.prefixLength(parts) <
best.prefixLength(parts))) {
best = candidate;
}
}
return best == null ? null : Pair.of(best, best.variables(parts));
}
````
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]