Skip to content

Commit

Permalink
fix: normalize the URL when checking for GitHub org (#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
bfabio authored Jul 31, 2024
1 parent af4b797 commit a278434
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,17 @@ function isValidPhoneNumber(phone) {
async function isGitHubValidated(url, ipaWebsite) {
let orgName = '';
try {
const u = new URL(url);
const cleanedUrl = url.endsWith('/')
? url.slice(0, -1)
: url;

const u = new URL(cleanedUrl);

if (u.hostname.replace(/^www\./, '') != 'github.com') {
return { error: 'Non è un URL GitHub' };
}

// Remove the trailing slash
orgName = u.pathname.substring(1);
orgName = u.pathname;
} catch {
return { error: 'Indirizzo non valido' };
}
Expand Down

0 comments on commit a278434

Please sign in to comment.