Skip to content

Commit

Permalink
fix short url in spaces (#58313)
Browse files Browse the repository at this point in the history
  • Loading branch information
flash1293 authored Feb 25, 2020
1 parent 1a15d3a commit a60b25f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/plugins/share/server/routes/goto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { schema } from '@kbn/config-schema';
import { shortUrlAssertValid } from './lib/short_url_assert_valid';
import { ShortUrlLookupService } from './lib/short_url_lookup';
import { getGotoPath } from '../../common/short_url_routes';
import { modifyUrl } from '../../../../core/utils';

export const createGotoRoute = ({
router,
Expand All @@ -49,9 +50,16 @@ export const createGotoRoute = ({
const uiSettings = context.core.uiSettings.client;
const stateStoreInSessionStorage = await uiSettings.get('state:storeInSessionStorage');
if (!stateStoreInSessionStorage) {
const basePath = http.basePath.get(request);

const prependedUrl = modifyUrl(url, parts => {
if (!parts.hostname && parts.pathname && parts.pathname.startsWith('/')) {
parts.pathname = `${basePath}${parts.pathname}`;
}
});
return response.redirected({
headers: {
location: http.basePath.prepend(url),
location: prependedUrl,
},
});
}
Expand Down

0 comments on commit a60b25f

Please sign in to comment.