mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
[CST-5729] Fix issue with undefined link type
This commit is contained in:
@@ -107,6 +107,7 @@ export class BitstreamDownloadPageComponent implements OnInit {
|
||||
let links = '';
|
||||
|
||||
signpostingLinks.forEach((link: SignpostingLink) => {
|
||||
links = links + (isNotEmpty(links) ? ', ' : '') + `<${link.href}> ; rel="${link.rel}"` + (isNotEmpty(link.type) ? ` ; type="${link.type}" ` : ' ');
|
||||
links = links + (isNotEmpty(links) ? ', ' : '') + `<${link.href}> ; rel="${link.rel}" ; type="${link.type}" `;
|
||||
});
|
||||
|
||||
|
@@ -49,7 +49,7 @@ const mocklink = {
|
||||
const mocklink2 = {
|
||||
href: 'http://test2.org',
|
||||
rel: 'rel2',
|
||||
type: 'type2'
|
||||
type: undefined
|
||||
};
|
||||
|
||||
const mockSignpostingLinks: SignpostingLink[] = [mocklink, mocklink2];
|
||||
@@ -176,13 +176,18 @@ describe('ItemPageComponent', () => {
|
||||
|
||||
// Check if linkHeadService.addTag() was called with the correct arguments
|
||||
expect(linkHeadService.addTag).toHaveBeenCalledTimes(mockSignpostingLinks.length);
|
||||
expect(linkHeadService.addTag).toHaveBeenCalledWith(mockSignpostingLinks[0] as LinkDefinition);
|
||||
expect(linkHeadService.addTag).toHaveBeenCalledWith(mockSignpostingLinks[1] as LinkDefinition);
|
||||
let expected: LinkDefinition = mockSignpostingLinks[0] as LinkDefinition;
|
||||
expect(linkHeadService.addTag).toHaveBeenCalledWith(expected);
|
||||
expected = {
|
||||
href: 'http://test2.org',
|
||||
rel: 'rel2'
|
||||
};
|
||||
expect(linkHeadService.addTag).toHaveBeenCalledWith(expected);
|
||||
});
|
||||
|
||||
it('should set Link header on the server', () => {
|
||||
|
||||
expect(serverResponseService.setHeader).toHaveBeenCalledWith('Link', '<http://test.org> ; rel="rel1" ; type="type1" , <http://test2.org> ; rel="rel2" ; type="type2" ');
|
||||
expect(serverResponseService.setHeader).toHaveBeenCalledWith('Link', '<http://test.org> ; rel="rel1" ; type="type1" , <http://test2.org> ; rel="rel2" ');
|
||||
});
|
||||
|
||||
});
|
||||
|
@@ -20,7 +20,7 @@ import { ServerResponseService } from '../../core/services/server-response.servi
|
||||
import { SignpostingDataService } from '../../core/data/signposting-data.service';
|
||||
import { SignpostingLink } from '../../core/data/signposting-links.model';
|
||||
import { isNotEmpty } from '../../shared/empty.util';
|
||||
import { LinkHeadService } from '../../core/services/link-head.service';
|
||||
import { LinkDefinition, LinkHeadService } from '../../core/services/link-head.service';
|
||||
|
||||
/**
|
||||
* This component renders a simple item page.
|
||||
@@ -111,12 +111,17 @@ export class ItemPageComponent implements OnInit, OnDestroy {
|
||||
this.signpostingLinks = signpostingLinks;
|
||||
|
||||
signpostingLinks.forEach((link: SignpostingLink) => {
|
||||
links = links + (isNotEmpty(links) ? ', ' : '') + `<${link.href}> ; rel="${link.rel}" ; type="${link.type}" `;
|
||||
this.linkHeadService.addTag({
|
||||
links = links + (isNotEmpty(links) ? ', ' : '') + `<${link.href}> ; rel="${link.rel}"` + (isNotEmpty(link.type) ? ` ; type="${link.type}" ` : ' ');
|
||||
let tag: LinkDefinition = {
|
||||
href: link.href,
|
||||
type: link.type,
|
||||
rel: link.rel
|
||||
});
|
||||
};
|
||||
if (isNotEmpty(link.type)) {
|
||||
tag = Object.assign(tag, {
|
||||
type: link.type
|
||||
});
|
||||
}
|
||||
this.linkHeadService.addTag(tag);
|
||||
});
|
||||
|
||||
if (isPlatformServer(this.platformId)) {
|
||||
|
Reference in New Issue
Block a user