Files
dspace-angular/src/app/shared/object-list/metadata-representation-list-element/metadata-representation-list-element.component.ts
Alexandre Vryghem abc8640b5e Fix MetadataRepresentationListElementComponent no expectation tests
Also fixed incorrect regex in isLink()
2023-07-01 20:38:16 +02:00

33 lines
947 B
TypeScript

import { Component, Input } from '@angular/core';
import { MetadataRepresentation } from '../../../core/shared/metadata-representation/metadata-representation.model';
import { Context } from '../../../core/shared/context.model';
@Component({
selector: 'ds-metadata-representation-list-element',
template: ''
})
/**
* An abstract class for displaying a single MetadataRepresentation
*/
export class MetadataRepresentationListElementComponent {
/**
* The optional context
*/
@Input() context: Context;
/**
* The metadata representation of this component
*/
@Input() mdRepresentation: MetadataRepresentation;
/**
* Returns true if this component's value matches a basic regex "Is this an HTTP URL" test
*/
isLink(): boolean {
// Match any string that begins with http:// or https://
const linkPattern = new RegExp(/^https?:\/\/.*/);
return linkPattern.test(this.mdRepresentation.getValue());
}
}