diff --git a/src/src/app/shared/linkify.pipe.ts b/src/src/app/shared/linkify.pipe.ts
index 66d5452..fee2bfc 100644
--- a/src/src/app/shared/linkify.pipe.ts
+++ b/src/src/app/shared/linkify.pipe.ts
@@ -5,13 +5,31 @@ import { DomSanitizer, SafeHtml } from "@angular/platform-browser";
export class LinkifyPipe implements PipeTransform {
constructor(private sanitizer: DomSanitizer) {}
+ private basicEscape(text: string): string {
+ return text.replace(
+ /[&<>"']/g,
+ (char) =>
+ ({
+ "&": "&",
+ "<": "<",
+ ">": ">",
+ '"': """,
+ "'": "'",
+ })[char]!,
+ );
+ }
+
transform(text: string): SafeHtml {
if (!text) return text;
const urlRegex = /((https?:\/\/|www\.)[^\s]+)/g;
- const html = text.replace(urlRegex, (url) => {
- return `${url}`;
+ const safeText = this.basicEscape(text);
+
+ const html = safeText.replace(urlRegex, (url) => {
+ const href = url.startsWith("http") ? url : `https://${url}`;
+ return `${url}`;
});
+
return this.sanitizer.bypassSecurityTrustHtml(html);
}
}