1234567891011121314151617181920212223242526272829 |
- 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 replaces 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;
- }
- }
|