Skip to content

Commit

Permalink
Fixes Jeager UI broken when accessing via IPv6 address (jaegertracing…
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahesh PAI R committed Dec 3, 2019
1 parent 0c175e1 commit 0764bc6
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/jaeger-ui/src/utils/prefix-url.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@

import sitePrefix from '../site-prefix';

/**
* Escape any RegEx characters in a given string
*
* @param {string} value The string which needs to be escaped
* @return {string} Escaped RegEx string
*/
function regExEscape(value?: string) {
const s = value == null ? '' : String(value);
return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
};

const origin = process.env.NODE_ENV === 'test' ? global.location.origin : window.location.origin;
/**
* Generate the URL prefix from `sitePrefix` and use it for all subsequent calls
Expand All @@ -24,7 +35,7 @@ const origin = process.env.NODE_ENV === 'test' ? global.location.origin : window
* - `"http://localhost:3000/abc/"` to `"/abc"`
* - `"http://localhost:3000/abc/def/"` to `"/abc/def"`
*/
const rx = new RegExp(`^${origin}|/$`, 'ig');
const rx = new RegExp(`^${regExEscape(origin)}|/$`, 'ig');
const pathPrefix = sitePrefix.replace(rx, '');

/**
Expand Down

0 comments on commit 0764bc6

Please sign in to comment.