Trotz der Implementierung von Bereinigungsmaßnahmen und Nach der Validierung besteht das Problem weiterhin. Hier ist die Funktion, die ich verwende:
Code: Select all
getDocs() {
this._service.getDocs(this.docID).subscribe(res => {
if (res) {
const sanitizedDocID = this.sanitizedDocID(this.docID);
if (res.lstDocs.length) {
const redirectUrl = `doc/${sanitizedDocID}`;
if (this.isValidRedirectUrl(redirectUrl)) {
this._router.navigateByUrl(redirectUrl);
}
} else if (!res.lstDocs.length && res.ListNewDocs.length) {
const redirectUrl = `new-doc/${sanitizedDocID}`;
if (this.isValidRedirectUrl(redirectUrl)) {
this._router.navigateByUrl(redirectUrl);
}
} else {
this._router.navigateByUrl('dashboard');
}
}
});
}
isValidRedirectUrl(url) {
const trustedUrls = ['doc', 'new-doc'];
return trustedUrls.indexOf(url) > -1;
}
sanitizedDocID(docId) {
return docId.replace(/[^0-9]/g, '');
}
Was kann noch getan werden, um dieses Problem zu beheben? Bitte helfen Sie uns.