1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2024-11-25 12:49:51 +01:00

Merge pull request #443 from wunter8/441-server-url-publish-trailing-slash

strip trailing slash after server url in publish dialog
This commit is contained in:
Philipp C. Heckel 2022-10-21 10:29:59 -04:00 committed by GitHub
commit 536b5d364a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -90,6 +90,14 @@ const PublishDialog = (props) => {
setMessage(props.message); setMessage(props.message);
}, [props.message]); }, [props.message]);
const updateBaseUrl = (newVal) => {
if (validUrl(newVal)) {
setBaseUrl(newVal.replace(/\/$/, '')); // strip traililng slash after https?://
} else {
setBaseUrl(newVal);
}
};
const handleSubmit = async () => { const handleSubmit = async () => {
const url = new URL(topicUrl(baseUrl, topic)); const url = new URL(topicUrl(baseUrl, topic));
if (title.trim()) { if (title.trim()) {
@ -242,7 +250,7 @@ const PublishDialog = (props) => {
label={t("publish_dialog_base_url_label")} label={t("publish_dialog_base_url_label")}
placeholder={t("publish_dialog_base_url_placeholder")} placeholder={t("publish_dialog_base_url_placeholder")}
value={baseUrl} value={baseUrl}
onChange={ev => setBaseUrl(ev.target.value)} onChange={ev => updateBaseUrl(ev.target.value)}
disabled={disabled} disabled={disabled}
type="url" type="url"
variant="standard" variant="standard"