Skip to content

Commit

Permalink
fix: added check for URL function
Browse files Browse the repository at this point in the history
  • Loading branch information
MGeovany committed Mar 27, 2024
1 parent 5760787 commit 859d811
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/utils/mainNameFromUrl.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
export default function getDomainNameFromUrl(urlString: string): string | null {
try {
if (!urlString) {
console.error("URL string is empty");
return null;
}

const { hostname } = new URL(urlString);
const domainName = hostname.replace(/^www\./, "");
return domainName;
Expand Down

0 comments on commit 859d811

Please sign in to comment.