handle onblur for emebed domains (#2199)

bump browser extension commit
handle onblur for emebed domains
This commit is contained in:
Timothy Carambat 2024-08-29 14:10:41 -07:00 committed by GitHub
parent 334fd9cdd0
commit bc0cc20678
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 1 deletions

@ -1 +1 @@
Subproject commit d9b28cc1e23b64fdb4e666d5b5b49cc8e583aabd
Subproject commit f2715e950e3c8afc471609afe518bf5452bc1049

View File

@ -250,6 +250,25 @@ export const PermittedDomains = ({ defaultValue = [] }) => {
setDomains(validDomains);
};
const handleBlur = (event) => {
const currentInput = event.target.value;
if (!currentInput) return;
const validDomains = [...domains, currentInput].map((input) => {
let url = input;
if (!url.includes("http://") && !url.includes("https://"))
url = `https://${url}`;
try {
new URL(url);
return url;
} catch {
return null;
}
});
event.target.value = "";
setDomains(validDomains);
};
return (
<div>
<div className="flex flex-col mb-2">
@ -270,6 +289,7 @@ export const PermittedDomains = ({ defaultValue = [] }) => {
<TagsInput
value={domains}
onChange={handleChange}
onBlur={handleBlur}
placeholder="https://mysite.com, https://anythingllm.com"
classNames={{
tag: "bg-blue-300/10 text-zinc-800 m-1",