Skip to content

Commit

Permalink
Configuring the URI link target
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorBaptist4 committed Sep 11, 2024
1 parent 16943fe commit 0ef2db1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@

<!-- Render value as a link (href and label) -->
<ng-template #link let-value="value">
<a class="dont-break-out ds-simple-metadata-link" target="_blank" [href]="value">
<a class="dont-break-out ds-simple-metadata-link"
[href]="value"
[attr.target]="getLinkAttributes(value).target"
[attr.rel]="getLinkAttributes(value).rel">
{{value}}
</a>
</ng-template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,16 @@ export class MetadataValuesComponent implements OnChanges {
hasInternalLink(linkValue: string): boolean {
return linkValue.startsWith(environment.ui.baseUrl);
}

/**
* This method performs a validation and determines the target of the url.
* @returns - Returns the target url.
*/
getLinkAttributes(urlValue: string): { target: string, rel: string } {

Check failure on line 142 in src/app/item-page/field-components/metadata-values/metadata-values.component.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

Expected indentation of 2 spaces but found 1

Check failure on line 142 in src/app/item-page/field-components/metadata-values/metadata-values.component.ts

View workflow job for this annotation

GitHub Actions / tests (20.x)

Expected indentation of 2 spaces but found 1
if (this.hasInternalLink(urlValue)) {
return { target: '_self', rel: '' };
} else {
return { target: '_blank', rel: 'noopener noreferrer' };
}
}
}

0 comments on commit 0ef2db1

Please sign in to comment.