Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/app/pages/domains/add/bulk-add/index.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,16 +200,18 @@ export default class BulkAddComponent implements OnInit, OnDestroy {
*/
parseDomainList(rawInput: string): string[] {
const lines = rawInput.split(/[\s,]+/);
// Example regex: supports e.g. "example.com" or "www.example.com"
const domainRegex =
/^(?:https?:\/\/)?(?:www\.)?([a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*\.[a-zA-Z]{2,})(?:\/.*)?$/;
/^(?:https?:\/\/)?(?:www\.)?([a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*)(?:\/.*)?$/i;

const result: string[] = [];
for (const line of lines) {
const match = line.trim().match(domainRegex);
if (match && match[1]) {
const domain = match[1].toLowerCase();
result.push(domain);
// Ensure it has at least one dot (is a valid domain)
if (domain.includes('.')) {
result.push(domain);
}
}
}
return result;
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/domains/add/index.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default class AddDomainComponent implements OnInit, OnDestroy {
this.domainForm = this.fb.group({
domainName: [this.initialDomain, [
Validators.required,
Validators.pattern(/^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9](\.[a-zA-Z]{2,})+$/),
Validators.pattern(/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i),
this.domainExistsValidator()
]],
registrar: ['', Validators.required],
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/domains/add/quick-add/index.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class QuickAddDomain {
domainForm = this.fb.group({
domainName: ['', [
Validators.required,
Validators.pattern(/^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9](\.[a-zA-Z]{2,})+$/)
Validators.pattern(/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i)
]],
});

Expand Down