Fix isInternalUrl for subdomain support

Refactor / reduce plumbing
This commit is contained in:
Tom Moor
2018-11-18 18:43:11 -08:00
parent cd1956b971
commit 032d843f5b
51 changed files with 13 additions and 98 deletions

View File

@@ -1,4 +0,0 @@
// @flow
import Actions from './Actions';
export { Action, Separator } from './Actions';
export default Actions;

View File

@@ -1,3 +0,0 @@
// @flow
import Alert from './Alert';
export default Alert;

View File

@@ -1,3 +0,0 @@
// @flow
import Button from './Button';
export default Button;

View File

@@ -1,3 +0,0 @@
// @flow
import CenteredContent from './CenteredContent';
export default CenteredContent;

View File

@@ -1,3 +0,0 @@
// @flow
import Collaborators from './Collaborators';
export default Collaborators;

View File

@@ -1,3 +0,0 @@
// @flow
import ColorPicker from './ColorPicker';
export default ColorPicker;

View File

@@ -1,3 +0,0 @@
// @flow
import CopyToClipboard from './CopyToClipboard';
export default CopyToClipboard;

View File

@@ -1,3 +0,0 @@
// @flow
import Divider from './Divider';
export default Divider;

View File

@@ -1,3 +0,0 @@
// @flow
import DropToImport from './DropToImport';
export default DropToImport;

View File

@@ -9,7 +9,6 @@ type Props = {
bodyPlaceholder?: string,
defaultValue?: string,
readOnly?: boolean,
expandToFit?: boolean,
history: *,
ui: *,
};

View File

@@ -1,3 +0,0 @@
// @flow
import Empty from './Empty';
export default Empty;

View File

@@ -1,3 +0,0 @@
// @flow
import Fade from './Fade';
export default Fade;

View File

@@ -1,3 +0,0 @@
// @flow
import HelpText from './HelpText';
export default HelpText;

View File

@@ -1,3 +0,0 @@
// @flow
import Highlight from './Highlight';
export default Highlight;

View File

@@ -1,4 +0,0 @@
// @flow
import Input, { LabelText, Outline } from './Input';
export default Input;
export { LabelText, Outline };

View File

@@ -1,3 +0,0 @@
// @flow
import Key from './key';
export default Key;

View File

@@ -1,4 +0,0 @@
// @flow
import Labeled, { Label } from './Labeled';
export default Labeled;
export { Label };

View File

@@ -1,3 +0,0 @@
// @flow
import Layout from './Layout';
export default Layout;

View File

@@ -1,3 +0,0 @@
// @flow
import Modal from './Modal';
export default Modal;

View File

@@ -1,3 +0,0 @@
// @flow
import Modals from './Modals';
export default Modals;

View File

@@ -1,3 +0,0 @@
// @flow
import PageTitle from './PageTitle';
export default PageTitle;

View File

@@ -1,4 +0,0 @@
// @flow
import Popover from './Popover';
export { Preset } from './Popover';
export default Popover;

View File

@@ -1,3 +0,0 @@
// @flow
import RouteSidebarHidden from './RouteSidebarHidden';
export default RouteSidebarHidden;

View File

@@ -1,3 +0,0 @@
// @flow
import Scrollable from './Scrollable';
export default Scrollable;

View File

@@ -1,15 +0,0 @@
// @flow
import styled from 'styled-components';
const Subheading = styled.h3`
font-size: 11px;
font-weight: 500;
text-transform: uppercase;
color: #9fa6ab;
letter-spacing: 0.04em;
border-bottom: 1px solid #ddd;
padding-bottom: 10px;
margin-top: 30px;
`;
export default Subheading;

View File

@@ -1,3 +0,0 @@
// @flow
import Subheading from './Subheading';
export default Subheading;

View File

@@ -1,12 +1,19 @@
// @flow
import parseDomain from 'parse-domain';
export default function isInternalUrl(href: string) {
if (href[0] === '/') return true;
try {
const outline = new URL(BASE_URL);
const parsed = new URL(href);
return parsed.hostname === outline.hostname;
} catch (err) {
return false;
const outline = parseDomain(BASE_URL);
const parsed = parseDomain(href);
if (
parsed &&
outline &&
parsed.domain === outline.domain &&
parsed.tld === outline.tld
) {
return true;
}
return false;
}