Skip to content

Commit c6aeb22

Browse files
[getsentry/action-github-commit] Auto commit
1 parent 232aa67 commit c6aeb22

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/components/githubDomainChecker.tsx

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ interface GitHubDomainCheckerProps {
99
export function GitHubDomainChecker({id}: GitHubDomainCheckerProps = {}) {
1010
const [domain, setDomain] = useState('');
1111
const [isValidDomain, setIsValidDomain] = useState(false);
12-
12+
1313
// Safe function to check if domain is github.com or its subdomain
1414
const isValidGitHubDomain = (input_domain: string): boolean => {
1515
try {
16-
const url = new URL(input_domain.startsWith('http') ? input_domain : `https://${input_domain}`);
16+
const url = new URL(
17+
input_domain.startsWith('http') ? input_domain : `https://${input_domain}`
18+
);
1719
const hostname = url.hostname.toLowerCase();
18-
20+
1921
// Exact match for github.com or valid subdomain (like gist.github.com)
2022
return hostname === 'github.com' || hostname.endsWith('.github.com');
2123
} catch {
@@ -26,12 +28,18 @@ export function GitHubDomainChecker({id}: GitHubDomainCheckerProps = {}) {
2628
// Safe function to check if it's an enterprise GitHub domain
2729
const isValidEnterpriseDomain = (input_domain: string): boolean => {
2830
try {
29-
const url = new URL(input_domain.startsWith('http') ? input_domain : `https://${input_domain}`);
31+
const url = new URL(
32+
input_domain.startsWith('http') ? input_domain : `https://${input_domain}`
33+
);
3034
const hostname = url.hostname.toLowerCase();
31-
35+
3236
// Must be a valid domain with TLD, but not github.com
3337
const domainPattern = /^[\w\-\.]+\.[\w]{2,}$/;
34-
return domainPattern.test(hostname) && !hostname.endsWith('.github.com') && hostname !== 'github.com';
38+
return (
39+
domainPattern.test(hostname) &&
40+
!hostname.endsWith('.github.com') &&
41+
hostname !== 'github.com'
42+
);
3543
} catch {
3644
return false;
3745
}
@@ -40,7 +48,7 @@ export function GitHubDomainChecker({id}: GitHubDomainCheckerProps = {}) {
4048
const isGitHubCom = (() => {
4149
const trimmedDomain = domain.toLowerCase().trim();
4250
if (!trimmedDomain) return false;
43-
51+
4452
return isValidGitHubDomain(trimmedDomain);
4553
})();
4654

@@ -53,7 +61,7 @@ export function GitHubDomainChecker({id}: GitHubDomainCheckerProps = {}) {
5361
setIsValidDomain(false);
5462
return;
5563
}
56-
64+
5765
// Check if it's a valid GitHub.com domain or subdomain
5866
if (isValidGitHubDomain(trimmedDomain)) {
5967
setIsValidDomain(true);

0 commit comments

Comments
 (0)