From 032d843f5bf5d2b3bcfe3160a1115251d277661a Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sun, 18 Nov 2018 18:43:11 -0800 Subject: [PATCH] Fix isInternalUrl for subdomain support Refactor / reduce plumbing --- app/components/{Actions => }/Actions.js | 0 app/components/Actions/index.js | 4 ---- app/components/{Alert => }/Alert.js | 0 app/components/Alert/index.js | 3 --- app/components/{Button => }/Button.js | 0 app/components/Button/index.js | 3 --- .../{CenteredContent => }/CenteredContent.js | 0 app/components/CenteredContent/index.js | 3 --- .../{Collaborators => }/Collaborators.js | 0 app/components/Collaborators/index.js | 3 --- .../{ColorPicker => }/ColorPicker.js | 0 app/components/ColorPicker/index.js | 3 --- .../{CopyToClipboard => }/CopyToClipboard.js | 0 app/components/CopyToClipboard/index.js | 3 --- app/components/{Divider => }/Divider.js | 0 app/components/Divider/index.js | 3 --- .../{DropToImport => }/DropToImport.js | 0 app/components/DropToImport/index.js | 3 --- app/components/Editor.js | 1 - app/components/{Empty => }/Empty.js | 0 app/components/Empty/index.js | 3 --- app/components/{Fade => }/Fade.js | 0 app/components/Fade/index.js | 3 --- app/components/{HelpText => }/HelpText.js | 0 app/components/HelpText/index.js | 3 --- app/components/{Highlight => }/Highlight.js | 0 app/components/Highlight/index.js | 3 --- app/components/{Input => }/Input.js | 0 app/components/Input/index.js | 4 ---- app/components/{Key/key.js => Key.js} | 0 app/components/Key/index.js | 3 --- app/components/{Labeled => }/Labeled.js | 0 app/components/Labeled/index.js | 4 ---- app/components/{Layout => }/Layout.js | 0 app/components/Layout/index.js | 3 --- app/components/{Modal => }/Modal.js | 0 app/components/Modal/index.js | 3 --- app/components/{Modals => }/Modals.js | 0 app/components/Modals/index.js | 3 --- app/components/{PageTitle => }/PageTitle.js | 0 app/components/PageTitle/index.js | 3 --- app/components/{Popover => }/Popover.js | 0 app/components/Popover/index.js | 4 ---- .../RouteSidebarHidden.js | 0 app/components/RouteSidebarHidden/index.js | 3 --- app/components/{Scrollable => }/Scrollable.js | 0 app/components/Scrollable/index.js | 3 --- app/components/Subheading/Subheading.js | 15 --------------- app/components/Subheading/index.js | 3 --- .../{Tooltip/index.js => Tooltip.js} | 0 app/utils/isInternalUrl.js | 19 +++++++++++++------ 51 files changed, 13 insertions(+), 98 deletions(-) rename app/components/{Actions => }/Actions.js (100%) delete mode 100644 app/components/Actions/index.js rename app/components/{Alert => }/Alert.js (100%) delete mode 100644 app/components/Alert/index.js rename app/components/{Button => }/Button.js (100%) delete mode 100644 app/components/Button/index.js rename app/components/{CenteredContent => }/CenteredContent.js (100%) delete mode 100644 app/components/CenteredContent/index.js rename app/components/{Collaborators => }/Collaborators.js (100%) delete mode 100644 app/components/Collaborators/index.js rename app/components/{ColorPicker => }/ColorPicker.js (100%) delete mode 100644 app/components/ColorPicker/index.js rename app/components/{CopyToClipboard => }/CopyToClipboard.js (100%) delete mode 100644 app/components/CopyToClipboard/index.js rename app/components/{Divider => }/Divider.js (100%) delete mode 100644 app/components/Divider/index.js rename app/components/{DropToImport => }/DropToImport.js (100%) delete mode 100644 app/components/DropToImport/index.js rename app/components/{Empty => }/Empty.js (100%) delete mode 100644 app/components/Empty/index.js rename app/components/{Fade => }/Fade.js (100%) delete mode 100644 app/components/Fade/index.js rename app/components/{HelpText => }/HelpText.js (100%) delete mode 100644 app/components/HelpText/index.js rename app/components/{Highlight => }/Highlight.js (100%) delete mode 100644 app/components/Highlight/index.js rename app/components/{Input => }/Input.js (100%) delete mode 100644 app/components/Input/index.js rename app/components/{Key/key.js => Key.js} (100%) delete mode 100644 app/components/Key/index.js rename app/components/{Labeled => }/Labeled.js (100%) delete mode 100644 app/components/Labeled/index.js rename app/components/{Layout => }/Layout.js (100%) delete mode 100644 app/components/Layout/index.js rename app/components/{Modal => }/Modal.js (100%) delete mode 100644 app/components/Modal/index.js rename app/components/{Modals => }/Modals.js (100%) delete mode 100644 app/components/Modals/index.js rename app/components/{PageTitle => }/PageTitle.js (100%) delete mode 100644 app/components/PageTitle/index.js rename app/components/{Popover => }/Popover.js (100%) delete mode 100644 app/components/Popover/index.js rename app/components/{RouteSidebarHidden => }/RouteSidebarHidden.js (100%) delete mode 100644 app/components/RouteSidebarHidden/index.js rename app/components/{Scrollable => }/Scrollable.js (100%) delete mode 100644 app/components/Scrollable/index.js delete mode 100644 app/components/Subheading/Subheading.js delete mode 100644 app/components/Subheading/index.js rename app/components/{Tooltip/index.js => Tooltip.js} (100%) diff --git a/app/components/Actions/Actions.js b/app/components/Actions.js similarity index 100% rename from app/components/Actions/Actions.js rename to app/components/Actions.js diff --git a/app/components/Actions/index.js b/app/components/Actions/index.js deleted file mode 100644 index 71c56fa85..000000000 --- a/app/components/Actions/index.js +++ /dev/null @@ -1,4 +0,0 @@ -// @flow -import Actions from './Actions'; -export { Action, Separator } from './Actions'; -export default Actions; diff --git a/app/components/Alert/Alert.js b/app/components/Alert.js similarity index 100% rename from app/components/Alert/Alert.js rename to app/components/Alert.js diff --git a/app/components/Alert/index.js b/app/components/Alert/index.js deleted file mode 100644 index 7c95883ce..000000000 --- a/app/components/Alert/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// @flow -import Alert from './Alert'; -export default Alert; diff --git a/app/components/Button/Button.js b/app/components/Button.js similarity index 100% rename from app/components/Button/Button.js rename to app/components/Button.js diff --git a/app/components/Button/index.js b/app/components/Button/index.js deleted file mode 100644 index 70118ffe8..000000000 --- a/app/components/Button/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// @flow -import Button from './Button'; -export default Button; diff --git a/app/components/CenteredContent/CenteredContent.js b/app/components/CenteredContent.js similarity index 100% rename from app/components/CenteredContent/CenteredContent.js rename to app/components/CenteredContent.js diff --git a/app/components/CenteredContent/index.js b/app/components/CenteredContent/index.js deleted file mode 100644 index a9c4ec1db..000000000 --- a/app/components/CenteredContent/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// @flow -import CenteredContent from './CenteredContent'; -export default CenteredContent; diff --git a/app/components/Collaborators/Collaborators.js b/app/components/Collaborators.js similarity index 100% rename from app/components/Collaborators/Collaborators.js rename to app/components/Collaborators.js diff --git a/app/components/Collaborators/index.js b/app/components/Collaborators/index.js deleted file mode 100644 index 68cac4de5..000000000 --- a/app/components/Collaborators/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// @flow -import Collaborators from './Collaborators'; -export default Collaborators; diff --git a/app/components/ColorPicker/ColorPicker.js b/app/components/ColorPicker.js similarity index 100% rename from app/components/ColorPicker/ColorPicker.js rename to app/components/ColorPicker.js diff --git a/app/components/ColorPicker/index.js b/app/components/ColorPicker/index.js deleted file mode 100644 index 84f7ebb8d..000000000 --- a/app/components/ColorPicker/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// @flow -import ColorPicker from './ColorPicker'; -export default ColorPicker; diff --git a/app/components/CopyToClipboard/CopyToClipboard.js b/app/components/CopyToClipboard.js similarity index 100% rename from app/components/CopyToClipboard/CopyToClipboard.js rename to app/components/CopyToClipboard.js diff --git a/app/components/CopyToClipboard/index.js b/app/components/CopyToClipboard/index.js deleted file mode 100644 index 4d0c0539a..000000000 --- a/app/components/CopyToClipboard/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// @flow -import CopyToClipboard from './CopyToClipboard'; -export default CopyToClipboard; diff --git a/app/components/Divider/Divider.js b/app/components/Divider.js similarity index 100% rename from app/components/Divider/Divider.js rename to app/components/Divider.js diff --git a/app/components/Divider/index.js b/app/components/Divider/index.js deleted file mode 100644 index 6d4a0889a..000000000 --- a/app/components/Divider/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// @flow -import Divider from './Divider'; -export default Divider; diff --git a/app/components/DropToImport/DropToImport.js b/app/components/DropToImport.js similarity index 100% rename from app/components/DropToImport/DropToImport.js rename to app/components/DropToImport.js diff --git a/app/components/DropToImport/index.js b/app/components/DropToImport/index.js deleted file mode 100644 index a95a2a44d..000000000 --- a/app/components/DropToImport/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// @flow -import DropToImport from './DropToImport'; -export default DropToImport; diff --git a/app/components/Editor.js b/app/components/Editor.js index adf0e72b3..b26e27026 100644 --- a/app/components/Editor.js +++ b/app/components/Editor.js @@ -9,7 +9,6 @@ type Props = { bodyPlaceholder?: string, defaultValue?: string, readOnly?: boolean, - expandToFit?: boolean, history: *, ui: *, }; diff --git a/app/components/Empty/Empty.js b/app/components/Empty.js similarity index 100% rename from app/components/Empty/Empty.js rename to app/components/Empty.js diff --git a/app/components/Empty/index.js b/app/components/Empty/index.js deleted file mode 100644 index 5c3c3a071..000000000 --- a/app/components/Empty/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// @flow -import Empty from './Empty'; -export default Empty; diff --git a/app/components/Fade/Fade.js b/app/components/Fade.js similarity index 100% rename from app/components/Fade/Fade.js rename to app/components/Fade.js diff --git a/app/components/Fade/index.js b/app/components/Fade/index.js deleted file mode 100644 index fd1199888..000000000 --- a/app/components/Fade/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// @flow -import Fade from './Fade'; -export default Fade; diff --git a/app/components/HelpText/HelpText.js b/app/components/HelpText.js similarity index 100% rename from app/components/HelpText/HelpText.js rename to app/components/HelpText.js diff --git a/app/components/HelpText/index.js b/app/components/HelpText/index.js deleted file mode 100644 index 968c478b8..000000000 --- a/app/components/HelpText/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// @flow -import HelpText from './HelpText'; -export default HelpText; diff --git a/app/components/Highlight/Highlight.js b/app/components/Highlight.js similarity index 100% rename from app/components/Highlight/Highlight.js rename to app/components/Highlight.js diff --git a/app/components/Highlight/index.js b/app/components/Highlight/index.js deleted file mode 100644 index 99f319532..000000000 --- a/app/components/Highlight/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// @flow -import Highlight from './Highlight'; -export default Highlight; diff --git a/app/components/Input/Input.js b/app/components/Input.js similarity index 100% rename from app/components/Input/Input.js rename to app/components/Input.js diff --git a/app/components/Input/index.js b/app/components/Input/index.js deleted file mode 100644 index e9b21f08b..000000000 --- a/app/components/Input/index.js +++ /dev/null @@ -1,4 +0,0 @@ -// @flow -import Input, { LabelText, Outline } from './Input'; -export default Input; -export { LabelText, Outline }; diff --git a/app/components/Key/key.js b/app/components/Key.js similarity index 100% rename from app/components/Key/key.js rename to app/components/Key.js diff --git a/app/components/Key/index.js b/app/components/Key/index.js deleted file mode 100644 index efe24263a..000000000 --- a/app/components/Key/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// @flow -import Key from './key'; -export default Key; diff --git a/app/components/Labeled/Labeled.js b/app/components/Labeled.js similarity index 100% rename from app/components/Labeled/Labeled.js rename to app/components/Labeled.js diff --git a/app/components/Labeled/index.js b/app/components/Labeled/index.js deleted file mode 100644 index c68dffece..000000000 --- a/app/components/Labeled/index.js +++ /dev/null @@ -1,4 +0,0 @@ -// @flow -import Labeled, { Label } from './Labeled'; -export default Labeled; -export { Label }; diff --git a/app/components/Layout/Layout.js b/app/components/Layout.js similarity index 100% rename from app/components/Layout/Layout.js rename to app/components/Layout.js diff --git a/app/components/Layout/index.js b/app/components/Layout/index.js deleted file mode 100644 index 62fb061d0..000000000 --- a/app/components/Layout/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// @flow -import Layout from './Layout'; -export default Layout; diff --git a/app/components/Modal/Modal.js b/app/components/Modal.js similarity index 100% rename from app/components/Modal/Modal.js rename to app/components/Modal.js diff --git a/app/components/Modal/index.js b/app/components/Modal/index.js deleted file mode 100644 index 907593356..000000000 --- a/app/components/Modal/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// @flow -import Modal from './Modal'; -export default Modal; diff --git a/app/components/Modals/Modals.js b/app/components/Modals.js similarity index 100% rename from app/components/Modals/Modals.js rename to app/components/Modals.js diff --git a/app/components/Modals/index.js b/app/components/Modals/index.js deleted file mode 100644 index df1b93027..000000000 --- a/app/components/Modals/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// @flow -import Modals from './Modals'; -export default Modals; diff --git a/app/components/PageTitle/PageTitle.js b/app/components/PageTitle.js similarity index 100% rename from app/components/PageTitle/PageTitle.js rename to app/components/PageTitle.js diff --git a/app/components/PageTitle/index.js b/app/components/PageTitle/index.js deleted file mode 100644 index f9286c54d..000000000 --- a/app/components/PageTitle/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// @flow -import PageTitle from './PageTitle'; -export default PageTitle; diff --git a/app/components/Popover/Popover.js b/app/components/Popover.js similarity index 100% rename from app/components/Popover/Popover.js rename to app/components/Popover.js diff --git a/app/components/Popover/index.js b/app/components/Popover/index.js deleted file mode 100644 index 7fee10fdb..000000000 --- a/app/components/Popover/index.js +++ /dev/null @@ -1,4 +0,0 @@ -// @flow -import Popover from './Popover'; -export { Preset } from './Popover'; -export default Popover; diff --git a/app/components/RouteSidebarHidden/RouteSidebarHidden.js b/app/components/RouteSidebarHidden.js similarity index 100% rename from app/components/RouteSidebarHidden/RouteSidebarHidden.js rename to app/components/RouteSidebarHidden.js diff --git a/app/components/RouteSidebarHidden/index.js b/app/components/RouteSidebarHidden/index.js deleted file mode 100644 index 0a92e652c..000000000 --- a/app/components/RouteSidebarHidden/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// @flow -import RouteSidebarHidden from './RouteSidebarHidden'; -export default RouteSidebarHidden; diff --git a/app/components/Scrollable/Scrollable.js b/app/components/Scrollable.js similarity index 100% rename from app/components/Scrollable/Scrollable.js rename to app/components/Scrollable.js diff --git a/app/components/Scrollable/index.js b/app/components/Scrollable/index.js deleted file mode 100644 index 1b6d57523..000000000 --- a/app/components/Scrollable/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// @flow -import Scrollable from './Scrollable'; -export default Scrollable; diff --git a/app/components/Subheading/Subheading.js b/app/components/Subheading/Subheading.js deleted file mode 100644 index fdc716489..000000000 --- a/app/components/Subheading/Subheading.js +++ /dev/null @@ -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; diff --git a/app/components/Subheading/index.js b/app/components/Subheading/index.js deleted file mode 100644 index d0f6a76e7..000000000 --- a/app/components/Subheading/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// @flow -import Subheading from './Subheading'; -export default Subheading; diff --git a/app/components/Tooltip/index.js b/app/components/Tooltip.js similarity index 100% rename from app/components/Tooltip/index.js rename to app/components/Tooltip.js diff --git a/app/utils/isInternalUrl.js b/app/utils/isInternalUrl.js index 4f1924235..48e36e338 100644 --- a/app/utils/isInternalUrl.js +++ b/app/utils/isInternalUrl.js @@ -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; }