1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2024-11-22 11:24:04 +01:00

strip trailing slash in "use another server" URL

fixes #428
This commit is contained in:
Hunter Kehoe 2022-10-08 17:20:14 -06:00
parent cbc912d1e3
commit dd689fd4a6

View file

@ -90,6 +90,13 @@ const SubscribePage = (props) => {
return validTopic(topic) && !isExistingTopicUrl;
}
})();
const updateBaseUrl = (ev, newVal) => {
if (validUrl(newVal)) {
props.setBaseUrl(newVal.replace(/\/$/, '')); // strip traililng / after https?://
} else {
props.setBaseUrl(newVal);
}
};
return (
<>
<DialogTitle>{t("subscribe_dialog_subscribe_title")}</DialogTitle>
@ -128,7 +135,7 @@ const SubscribePage = (props) => {
options={existingBaseUrls}
sx={{ maxWidth: 400 }}
inputValue={props.baseUrl}
onInputChange={(ev, newVal) => props.setBaseUrl(newVal)}
onInputChange={updateBaseUrl}
renderInput={ (params) =>
<TextField
{...params}