mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Url parsing
Lint fix
This commit is contained in:
@@ -17,7 +17,7 @@ import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { Bitstream } from '../../../../core/shared/bitstream.model';
|
||||
import { HALEndpointService } from '../../../../core/shared/hal-endpoint.service';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { MetadataMap, MetadataValue } from '../../../../core/shared/metadata.models';
|
||||
import { MetadataMap } from '../../../../core/shared/metadata.models';
|
||||
import { UUIDService } from '../../../../core/shared/uuid.service';
|
||||
import { TranslateLoaderMock } from '../../../../shared/mocks/translate-loader.mock';
|
||||
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
|
||||
@@ -31,7 +31,6 @@ import {
|
||||
import { PublicationComponent } from './publication.component';
|
||||
import { createPaginatedList } from '../../../../shared/testing/utils.test';
|
||||
import { RouteService } from '../../../../core/services/route.service';
|
||||
import { UntypedItemComponent } from '../untyped-item/untyped-item.component';
|
||||
|
||||
const noMetadata = new MetadataMap();
|
||||
|
||||
@@ -155,7 +154,7 @@ describe('PublicationComponent', () => {
|
||||
beforeEach(waitForAsync(() => {
|
||||
const localMockRouteService = {
|
||||
getPreviousUrl(): Observable<string> {
|
||||
return of('/search?query=test');
|
||||
return of('/search?query=test%20query&fakeParam=true');
|
||||
}
|
||||
};
|
||||
const iiifEnabledMap: MetadataMap = {
|
||||
@@ -176,8 +175,7 @@ describe('PublicationComponent', () => {
|
||||
});
|
||||
|
||||
it('should retrieve the query term for previous route', fakeAsync((): void => {
|
||||
//tick(10)
|
||||
expect(comp.iiifQuery$.subscribe(result => expect(result).toEqual('test')));
|
||||
expect(comp.iiifQuery$.subscribe(result => expect(result).toEqual('test query')));
|
||||
}));
|
||||
|
||||
});
|
||||
|
@@ -2,6 +2,7 @@ import { Item } from '../../../../core/shared/item.model';
|
||||
import { Observable } from 'rxjs';
|
||||
import { filter, map, take } from 'rxjs/operators';
|
||||
import { RouteService } from '../../../../core/services/route.service';
|
||||
import { DefaultUrlSerializer, UrlTree } from '@angular/router';
|
||||
|
||||
export const isIiifEnabled = (item: Item) => {
|
||||
return !!item.firstMetadataValue('dspace.iiif.enabled');
|
||||
@@ -21,13 +22,14 @@ export const isIiifSearchEnabled = (item: Item) => {
|
||||
* @param routeService
|
||||
*/
|
||||
export const getDSpaceQuery = (item: Item, routeService: RouteService): Observable<string> => {
|
||||
|
||||
return routeService.getPreviousUrl().pipe(
|
||||
filter(r => {
|
||||
return r.includes('/search');
|
||||
}),
|
||||
map(r => {
|
||||
const v = r.split('query=');
|
||||
return v[1];
|
||||
map((r: string) => {
|
||||
const url: UrlTree = new DefaultUrlSerializer().parse(r);
|
||||
return url.queryParamMap.get('query');
|
||||
}),
|
||||
take(1)
|
||||
);
|
||||
|
@@ -173,7 +173,7 @@ describe('UntypedItemComponent', () => {
|
||||
beforeEach(waitForAsync(() => {
|
||||
const localMockRouteService = {
|
||||
getPreviousUrl(): Observable<string> {
|
||||
return of('/search?query=test');
|
||||
return of('/search?query=test%20query&fakeParam=true');
|
||||
}
|
||||
};
|
||||
const iiifEnabledMap: MetadataMap = {
|
||||
@@ -194,7 +194,7 @@ describe('UntypedItemComponent', () => {
|
||||
});
|
||||
|
||||
it('should retrieve the query term for previous route', (): void => {
|
||||
expect(comp.iiifQuery$.subscribe(result => expect(result).toEqual('test')));
|
||||
expect(comp.iiifQuery$.subscribe(result => expect(result).toEqual('test query')));
|
||||
});
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user