|
@@ -0,0 +1,22 @@
|
|
|
+import { Pipe, PipeTransform } from '@angular/core';
|
|
|
+
|
|
|
+/**
|
|
|
+ * Generated class for the ReplaceUrlsPipe pipe.
|
|
|
+ *
|
|
|
+ * See https://angular.io/api/core/Pipe for more info on Angular Pipes.
|
|
|
+ */
|
|
|
+@Pipe({
|
|
|
+ name: 'replaceUrls',
|
|
|
+})
|
|
|
+export class ReplaceUrlsPipe implements PipeTransform {
|
|
|
+ /**
|
|
|
+ * Takes a string and replace the urls with hyperlinks.
|
|
|
+ */
|
|
|
+ transform(value: string, ...args) {
|
|
|
+ for (let url of args[0]) {
|
|
|
+ value = value.replace(url["url"], '<a href="' + url["expanded_url"] + '" target="_blank">' + url["display_url"] + '</a>');
|
|
|
+ }
|
|
|
+
|
|
|
+ return value;
|
|
|
+ }
|
|
|
+}
|