fix: ignore trailing slash for autogenerated name (#7307)

- During the migration process, if a valid GitHub clone URL was pasted, https://github.com/yuvipanda/notebooksharing.space/, the form automatically generates an invalid Forgejo repository name that included the trailing slash.
- Change the regex used to generate the name to ignore the trailing slash.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7307
Reviewed-by: Otto <otto@codeberg.org>
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: YuviPanda <yuvipanda@gmail.com>
Co-committed-by: YuviPanda <yuvipanda@gmail.com>
This commit is contained in:
YuviPanda 2025-03-29 19:35:01 +00:00 committed by Gusted
parent 8df8381f51
commit c9853e9e3a
2 changed files with 29 additions and 1 deletions

View file

@ -29,7 +29,7 @@ export function initRepoMigration() {
cloneAddr?.addEventListener('change', () => {
const repoName = document.getElementById('repo_name');
if (cloneAddr.value && !repoName?.value) { // Only modify if repo_name input is blank
repoName.value = cloneAddr.value.match(/^(.*\/)?((.+?)(\.git)?)$/)[3];
repoName.value = cloneAddr.value.match(/^(.*\/)?((.+?)(\.git)?\/?)$/)[3];
}
});
}