Use regex for query route pattern
Query URLs in GWT permitted un-encoded slashes in project operators, however the route pattern for queries in PolyGerrit used the string style of definition which would not permit slashes in params. With this change, the two patterns for searches are unified into a single regex style of definition which permits such slashes. Bug: Issue 7306 Bug: Issue 9231 Change-Id: I597d9f0f3d1cb747998bb4213e21a663944f9ce6
This commit is contained in:

committed by
Paladox none

parent
36d32d9d6c
commit
e0b0449cce
@@ -87,8 +87,7 @@
|
||||
PLUGIN_LIST_FILTER: '/admin/plugins/q/filter::filter',
|
||||
PLUGIN_LIST_FILTER_OFFSET: '/admin/plugins/q/filter::filter,:offset',
|
||||
|
||||
QUERY: '/q/:query',
|
||||
QUERY_OFFSET: '/q/:query,:offset',
|
||||
QUERY: /^\/q\/([^,]+)(,(\d+))?$/,
|
||||
|
||||
/**
|
||||
* Support vestigial params from GWT UI.
|
||||
@@ -550,7 +549,6 @@
|
||||
this._mapRoute(RoutePattern.ADMIN_PLACEHOLDER,
|
||||
'_handleAdminPlaceholderRoute', true);
|
||||
|
||||
this._mapRoute(RoutePattern.QUERY_OFFSET, '_handleQueryRoute');
|
||||
this._mapRoute(RoutePattern.QUERY, '_handleQueryRoute');
|
||||
|
||||
this._mapRoute(RoutePattern.DIFF_LEGACY_LINENUM, '_handleLegacyLinenum');
|
||||
@@ -877,8 +875,11 @@
|
||||
},
|
||||
|
||||
_handleQueryRoute(data) {
|
||||
data.params.view = Gerrit.Nav.View.SEARCH;
|
||||
this._setParams(data.params);
|
||||
this._setParams({
|
||||
view: Gerrit.Nav.View.SEARCH,
|
||||
query: data.params[0],
|
||||
offset: data.params[2],
|
||||
});
|
||||
},
|
||||
|
||||
_handleQueryLegacySuffixRoute(ctx) {
|
||||
|
@@ -486,6 +486,22 @@ limitations under the License.
|
||||
assert.equal(redirectStub.lastCall.args[0], '/q/foo+bar');
|
||||
});
|
||||
|
||||
test('_handleQueryRoute', () => {
|
||||
const data = {params: ['project:foo/bar/baz']};
|
||||
assertDataToParams(data, '_handleQueryRoute', {
|
||||
view: Gerrit.Nav.View.SEARCH,
|
||||
query: 'project:foo/bar/baz',
|
||||
offset: undefined,
|
||||
});
|
||||
|
||||
data.params.push(',123', '123');
|
||||
assertDataToParams(data, '_handleQueryRoute', {
|
||||
view: Gerrit.Nav.View.SEARCH,
|
||||
query: 'project:foo/bar/baz',
|
||||
offset: '123',
|
||||
});
|
||||
});
|
||||
|
||||
suite('_handleRegisterRoute', () => {
|
||||
test('happy path', () => {
|
||||
const ctx = {params: ['/foo/bar']};
|
||||
|
Reference in New Issue
Block a user