Skip to content

Commit

Permalink
Improve variable
Browse files Browse the repository at this point in the history
  • Loading branch information
cnasikas committed Sep 16, 2020
1 parent 7185d51 commit b2f5d9d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export {

interface FormatUrlOptions {
absolute: boolean;
addSearch: boolean;
skipSearch: boolean;
}

type FormatUrl = (path: string, options?: Partial<FormatUrlOptions>) => string;
Expand All @@ -36,10 +36,10 @@ export const useFormatUrl = (page: SecurityPageName) => {
const { getUrlForApp } = useKibana().services.application;
const search = useGetUrlSearch(navTabs[page]);
const formatUrl = useCallback<FormatUrl>(
(path: string, { absolute, addSearch } = { absolute: false, addSearch: true }) => {
(path: string, { absolute = false, skipSearch = false } = {}) => {
const pathArr = path.split('?');
const formattedPath = `${pathArr[0]}${
addSearch
!skipSearch
? isEmpty(pathArr[1])
? search
: `?${pathArr[1]}${isEmpty(search) ? '' : `&${search}`}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const TimelineEditorComponent: React.FC<TimelineEditorProps> = ({ onClosePopover
onTimelineChange={(timelineTitle, timelineId, graphEventId) => {
const url = formatUrl(getTimelineUrl(timelineId ?? '', graphEventId), {
absolute: true,
addSearch: false,
skipSearch: true,
});
onInsert(`[${timelineTitle}](${url})`, {
block: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const useInsertTimeline = (value: string, onChange: (newValue: string) =>
(title: string, id: string | null, graphEventId?: string) => {
const url = formatUrl(getTimelineUrl(id ?? '', graphEventId), {
absolute: true,
addSearch: false,
skipSearch: true,
});

const newValue: string = [
Expand Down

0 comments on commit b2f5d9d

Please sign in to comment.