mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-18 15:23:38 +01:00
Added safeDecodeURI method. Closes #848.
This commit is contained in:
parent
b6ab8c381f
commit
65d4094095
@ -4,6 +4,7 @@ import classNames from 'classnames';
|
||||
import Link from 'next/link';
|
||||
import FilterButtons from 'components/common/FilterButtons';
|
||||
import { urlFilter } from 'lib/filters';
|
||||
import { safeDecodeURI } from 'lib/url';
|
||||
import usePageQuery from 'hooks/usePageQuery';
|
||||
import MetricsTable from './MetricsTable';
|
||||
import styles from './PagesTable.module.css';
|
||||
@ -35,7 +36,7 @@ export default function PagesTable({ websiteId, websiteDomain, showFilters, ...p
|
||||
[styles.active]: x === url,
|
||||
})}
|
||||
>
|
||||
{decodeURI(x)}
|
||||
{safeDecodeURI(x)}
|
||||
</a>
|
||||
</Link>
|
||||
);
|
||||
|
@ -3,6 +3,7 @@ import { FormattedMessage } from 'react-intl';
|
||||
import MetricsTable from './MetricsTable';
|
||||
import FilterButtons from 'components/common/FilterButtons';
|
||||
import { refFilter } from 'lib/filters';
|
||||
import { safeDecodeURI } from 'lib/url';
|
||||
|
||||
export const FILTER_DOMAIN_ONLY = 0;
|
||||
export const FILTER_COMBINED = 1;
|
||||
@ -26,10 +27,10 @@ export default function ReferrersTable({ websiteId, websiteDomain, showFilters,
|
||||
const renderLink = ({ w: href, x: url }) => {
|
||||
return (href || url).startsWith('http') ? (
|
||||
<a href={href || url} target="_blank" rel="noreferrer">
|
||||
{decodeURI(url)}
|
||||
{safeDecodeURI(url)}
|
||||
</a>
|
||||
) : (
|
||||
decodeURI(url)
|
||||
safeDecodeURI(url)
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -32,3 +32,12 @@ export function getQueryString(params = {}) {
|
||||
export function makeUrl(url, params) {
|
||||
return `${url}${getQueryString(params)}`;
|
||||
}
|
||||
|
||||
export function safeDecodeURI(s) {
|
||||
try {
|
||||
return decodeURI(s);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user