Skip to content

Commit

Permalink
[Discover] Context - Fix bug when document id contains a slash (#77435)
Browse files Browse the repository at this point in the history
  • Loading branch information
kertal authored Sep 24, 2020
1 parent 9ca2238 commit 8ad53d5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
30 changes: 11 additions & 19 deletions src/plugins/discover/public/application/angular/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,18 @@ const k7Breadcrumbs = ($route) => {
};

getAngularModule().config(($routeProvider) => {
$routeProvider
// deprecated route, kept for compatibility
// should be removed in the future
.when('/context/:indexPatternId/:type/:id*', {
redirectTo: '/context/:indexPatternId/:id',
})
.when('/context/:indexPatternId/:id*', {
controller: ContextAppRouteController,
k7Breadcrumbs,
controllerAs: 'contextAppRoute',
resolve: {
indexPattern: ($route, Promise) => {
const indexPattern = getServices().indexPatterns.get(
$route.current.params.indexPatternId
);
return Promise.props({ ip: indexPattern });
},
$routeProvider.when('/context/:indexPatternId/:id*', {
controller: ContextAppRouteController,
k7Breadcrumbs,
controllerAs: 'contextAppRoute',
resolve: {
indexPattern: ($route, Promise) => {
const indexPattern = getServices().indexPatterns.get($route.current.params.indexPatternId);
return Promise.props({ ip: indexPattern });
},
template: contextAppRouteTemplate,
});
},
template: contextAppRouteTemplate,
});
});

function ContextAppRouteController($routeParams, $scope, $route) {
Expand Down
8 changes: 8 additions & 0 deletions src/plugins/discover/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,14 @@ export class DiscoverPlugin
return `#${path}`;
});
plugins.urlForwarding.forwardApp('context', 'discover', (path) => {
const urlParts = path.split('/');
// take care of urls containing legacy url, those split in the following way
// ["", "context", indexPatternId, _type, id + params]
if (urlParts[4]) {
// remove _type part
const newPath = [...urlParts.slice(0, 3), ...urlParts.slice(4)].join('/');
return `#${newPath}`;
}
return `#${path}`;
});
plugins.urlForwarding.forwardApp('discover', 'discover', (path) => {
Expand Down

0 comments on commit 8ad53d5

Please sign in to comment.