|
|
|
@ -38,7 +38,7 @@ class Link extends Component {
|
|
|
|
|
const linkProps = { target };
|
|
|
|
|
let el = component;
|
|
|
|
|
|
|
|
|
|
if (to) {
|
|
|
|
|
if (to && typeof to === 'string') {
|
|
|
|
|
if ((/\w+?:\/\//).test(to)) {
|
|
|
|
|
el = 'a';
|
|
|
|
|
linkProps.href = to;
|
|
|
|
@ -56,6 +56,18 @@ class Link extends Component {
|
|
|
|
|
linkProps.to = `${window.Lidarr.urlBase}/${to.replace(/^\//, '')}`;
|
|
|
|
|
linkProps.target = target;
|
|
|
|
|
}
|
|
|
|
|
} else if (to && typeof to === 'object') {
|
|
|
|
|
el = RouterLink;
|
|
|
|
|
linkProps.target = target;
|
|
|
|
|
if (to.pathname.startsWith(`${window.Lidarr.urlBase}/`)) {
|
|
|
|
|
linkProps.to = to;
|
|
|
|
|
} else {
|
|
|
|
|
const pathname = `${window.Lidarr.urlBase}/${to.pathname.replace(/^\//, '')}`;
|
|
|
|
|
linkProps.to = {
|
|
|
|
|
...to,
|
|
|
|
|
pathname
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (el === 'button' || el === 'input') {
|
|
|
|
@ -86,7 +98,7 @@ class Link extends Component {
|
|
|
|
|
Link.propTypes = {
|
|
|
|
|
className: PropTypes.string,
|
|
|
|
|
component: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
|
|
|
|
to: PropTypes.string,
|
|
|
|
|
to: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
|
|
|
target: PropTypes.string,
|
|
|
|
|
isDisabled: PropTypes.bool,
|
|
|
|
|
noRouter: PropTypes.bool,
|
|
|
|
|