fix(#10): slugify the appName and remove weird characters

This commit is contained in:
Mauricio Siu
2024-05-01 10:14:36 -06:00
parent 440f3e7f0f
commit 714444d1d6
2 changed files with 20 additions and 6 deletions

View File

@@ -31,6 +31,14 @@ export const generateName = () => {
n2[Math.round(Math.random() * (n2.length - 1))] n2[Math.round(Math.random() * (n2.length - 1))]
}`; }`;
}; };
function slugify(text: string) {
return text
.toLowerCase()
.replace(/[\s\^&*()+=!]+/g, "-")
.replace(/[\$.,*+~()'"!:@^&]+/g, "")
.replace(/-+/g, "-")
.replace(/^-+|-+$/g, "");
}
export const GithubSetup = () => { export const GithubSetup = () => {
const [isOrganization, setIsOrganization] = useState(false); const [isOrganization, setIsOrganization] = useState(false);
@@ -98,12 +106,17 @@ export const GithubSetup = () => {
your GitHub account. your GitHub account.
</span> </span>
<Link <div className="flex flex-row gap-4">
href={`https://github.com/apps/${data.githubAppName}/installations/new?state=gh_setup:${data?.authId}`} <Link
className={buttonVariants({ className: "w-fit" })} href={`https://github.com/apps/${slugify(
> data.githubAppName,
Install Github App )}/installations/new?state=gh_setup:${data?.authId}`}
</Link> className={buttonVariants({ className: "w-fit" })}
>
Install Github App
</Link>
<RemoveGithubApp />
</div>
</div> </div>
) : ( ) : (
<div> <div>

View File

@@ -39,6 +39,7 @@ export const RemoveGithubApp = () => {
await mutateAsync() await mutateAsync()
.then(async () => { .then(async () => {
await refetch(); await refetch();
utils.admin.one.invalidate();
await utils.admin.haveGithubConfigured.invalidate(); await utils.admin.haveGithubConfigured.invalidate();
toast.success("Github application deleted succesfully."); toast.success("Github application deleted succesfully.");
}) })