diff --git a/frontend/src/app/components/search-form/search-form.component.ts b/frontend/src/app/components/search-form/search-form.component.ts index d5edc8f7e..dd0acb874 100644 --- a/frontend/src/app/components/search-form/search-form.component.ts +++ b/frontend/src/app/components/search-form/search-form.component.ts @@ -23,9 +23,9 @@ export class SearchFormComponent implements OnInit { searchForm: FormGroup; @Output() searchTriggered = new EventEmitter(); - regexAddress = /([a-km-zA-HJ-NP-Z1-9]{26,35}|[a-km-zA-HJ-NP-Z1-9]{80}|[bB]?[a-z]{2,5}1[ac-hj-np-z02-9]{8,87})/; - regexBlockhash = /[0]{8}[a-fA-F0-9]{56}/; - regexTransaction = /([a-fA-F0-9]{64}):?(\d+)?/; + regexAddress = /^([a-km-zA-HJ-NP-Z1-9]{26,35}|[a-km-zA-HJ-NP-Z1-9]{80}|[bB]?[a-z]{2,5}1[ac-hj-np-z02-9]{8,87})$/; + regexBlockhash = /^[0]{8}[a-fA-F0-9]{56}$/; + regexTransaction = /^[a-fA-F0-9]{64}$/; regexBlockheight = /^[0-9]+$/; @ViewChild('instance', {static: true}) instance: NgbTypeahead; @@ -96,26 +96,21 @@ export class SearchFormComponent implements OnInit { if (searchText) { this.isSearching = true; if (this.regexAddress.test(searchText)) { - const matches = this.regexAddress.exec(searchText); - this.navigate('/address/', matches[0]); - } else if (this.regexBlockhash.test(searchText)) { - const matches = this.regexBlockhash.exec(searchText); - this.navigate('/block/', matches[0]); - } else if (this.regexBlockheight.test(searchText)) { + this.navigate('/address/', searchText); + } else if (this.regexBlockhash.test(searchText) || this.regexBlockheight.test(searchText)) { this.navigate('/block/', searchText); } else if (this.regexTransaction.test(searchText)) { - const matches = this.regexTransaction.exec(searchText); if (this.network === 'liquid') { - if (this.assets[matches[0]]) { - this.navigate('/asset/', matches[0]); + if (this.assets[searchText]) { + this.navigate('/asset/', searchText); } - this.electrsApiService.getAsset$(matches[0]) + this.electrsApiService.getAsset$(searchText) .subscribe( - () => { this.navigate('/asset/', matches[0]); }, - () => { this.navigate('/tx/', matches[0]); } + () => { this.navigate('/asset/', searchText); }, + () => { this.navigate('/tx/', searchText); } ); } else { - this.navigate('/tx/', matches[0]); + this.navigate('/tx/', searchText); } } else { this.isSearching = false; diff --git a/frontend/src/app/components/transaction/transaction.component.html b/frontend/src/app/components/transaction/transaction.component.html index a3b2b9db2..ed35889e8 100644 --- a/frontend/src/app/components/transaction/transaction.component.html +++ b/frontend/src/app/components/transaction/transaction.component.html @@ -198,7 +198,7 @@
-