Browse Source

Remove now unused splitTopicUrl function

Philipp Heckel 3 years ago
parent
commit
3f96fad7ce
2 changed files with 2 additions and 20 deletions
  1. 0 18
      web/src/app/utils.js
  2. 2 2
      web/src/components/SendDialog.js

+ 0 - 18
web/src/app/utils.js

@@ -23,28 +23,10 @@ export const shortUrl = (url) => url.replaceAll(/https?:\/\//g, "");
 export const expandUrl = (url) => [`https://${url}`, `http://${url}`];
 export const expandSecureUrl = (url) => `https://${url}`;
 
-export const splitTopicUrl = (url) => {
-    if (!validTopicUrl(url)) {
-        throw new Error("Invalid topic URL");
-    }
-    const parts = url.split("/");
-    if (parts.length < 2) {
-        throw new Error("Invalid topic URL");
-    }
-    return {
-        baseUrl: parts.slice(0, parts.length-1).join("/"),
-        topic: parts[parts.length-1]
-    };
-};
-
 export const validUrl = (url) => {
     return url.match(/^https?:\/\//);
 }
 
-export const validTopicUrl = (url) => {
-    return url.match(/^https?:\/\/.+\/.*[^/]/); // At least one other slash
-}
-
 export const validTopic = (topic) => {
     if (disallowedTopic(topic)) {
         return false;

+ 2 - 2
web/src/components/SendDialog.js

@@ -18,7 +18,7 @@ import IconButton from "@mui/material/IconButton";
 import InsertEmoticonIcon from '@mui/icons-material/InsertEmoticon';
 import {Close} from "@mui/icons-material";
 import MenuItem from "@mui/material/MenuItem";
-import {basicAuth, formatBytes, topicShortUrl, topicUrl, validTopicUrl} from "../app/utils";
+import {basicAuth, formatBytes, topicShortUrl, validTopic, validUrl} from "../app/utils";
 import Box from "@mui/material/Box";
 import AttachmentIcon from "./AttachmentIcon";
 import DialogFooter from "./DialogFooter";
@@ -80,7 +80,7 @@ const SendDialog = (props) => {
     }, [props.baseUrl, props.topic]);
 
     useEffect(() => {
-        const valid = validTopicUrl(topicUrl(baseUrl, topic)) && !attachFileError;
+        const valid = validUrl(baseUrl) && validTopic(topic) && !attachFileError;
         setSendButtonEnabled(valid);
     }, [baseUrl, topic, attachFileError]);