Skip to content

Commit

Permalink
handle non-existent domains and run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
stjet committed Nov 22, 2024
1 parent 8e41944 commit 18e7e2d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/app/navigation/search-bar/search-bar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ export class SearchBarComponent implements OnInit, AfterViewInit, AfterViewCheck
return this.invalidSearch.emit();
}

if (this._searchService.isValidAddress(value) || this._searchService.isValidBlock(value) || this._searchService.isValidBNSDomain(value)) {
if (
this._searchService.isValidAddress(value) ||
this._searchService.isValidBlock(value) ||
this._searchService.isValidBNSDomain(value)
) {
return this._emitSearch(value, controlKey);
}

Expand Down
12 changes: 7 additions & 5 deletions src/app/pages/account/account.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,15 @@ export class AccountComponent implements OnDestroy {
}

if (!address.startsWith('ban_')) {
const parts = address.split(".");
const parts = address.split('.');
if (parts.length === 2) {
//search in api
const domain = await this.apiService.fetchBNSDomain(parts[0], parts[1]);
if (domain.domain?.resolved_address) {
return this._redirectToAccountPage(domain.domain?.resolved_address);
}
try {
const domain = await this.apiService.fetchBNSDomain(parts[0], parts[1]);
if (domain.domain?.resolved_address) {
return this._redirectToAccountPage(domain.domain?.resolved_address);
}
} catch (_) {}
}
this._redirectToHashPage(address);
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/search/search.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class SearchService {
}

isValidBNSDomain(bns: string): boolean {
const parts = bns.split(".");
const parts = bns.split('.');
//later, can also check for illegal characters once that is more settled
return parts.length === 2 && parts[0].length <= 32;
}
Expand Down

0 comments on commit 18e7e2d

Please sign in to comment.