@@ -3,6 +3,9 @@ import { Config } from './config.interface';
33import { hasValue , hasNoValue , isNotEmpty } from '../app/shared/empty.util' ;
44import { DSpaceObject } from '../app/core/shared/dspace-object.model' ;
55import { getDSORoute } from '../app/app-routing-paths' ;
6+ import { HandleObject } from '../app/core/shared/handle-object.model' ;
7+ import { Injector } from '@angular/core' ;
8+ import { HandleService } from '../app/shared/handle.service' ;
69
710export interface NamedThemeConfig extends Config {
811 name : string ;
@@ -82,12 +85,20 @@ export class RegExTheme extends Theme {
8285}
8386
8487export class HandleTheme extends Theme {
85- constructor ( public config : HandleThemeConfig ) {
88+
89+ private normalizedHandle ;
90+
91+ constructor ( public config : HandleThemeConfig ,
92+ protected handleService : HandleService
93+ ) {
8694 super ( config ) ;
95+ this . normalizedHandle = this . handleService . normalizeHandle ( this . config . handle ) ;
96+
8797 }
8898
89- matches ( url : string , dso : any ) : boolean {
90- return hasValue ( dso ) && hasValue ( dso . handle ) && dso . handle . includes ( this . config . handle ) ;
99+ matches < T extends DSpaceObject & HandleObject > ( url : string , dso : T ) : boolean {
100+ return hasValue ( dso ) && hasValue ( dso . handle )
101+ && this . handleService . normalizeHandle ( dso . handle ) === this . normalizedHandle ;
91102 }
92103}
93104
@@ -101,11 +112,11 @@ export class UUIDTheme extends Theme {
101112 }
102113}
103114
104- export const themeFactory = ( config : ThemeConfig ) : Theme => {
115+ export const themeFactory = ( config : ThemeConfig , injector : Injector ) : Theme => {
105116 if ( hasValue ( ( config as RegExThemeConfig ) . regex ) ) {
106117 return new RegExTheme ( config as RegExThemeConfig ) ;
107118 } else if ( hasValue ( ( config as HandleThemeConfig ) . handle ) ) {
108- return new HandleTheme ( config as HandleThemeConfig ) ;
119+ return new HandleTheme ( config as HandleThemeConfig , injector . get ( HandleService ) ) ;
109120 } else if ( hasValue ( ( config as UUIDThemeConfig ) . uuid ) ) {
110121 return new UUIDTheme ( config as UUIDThemeConfig ) ;
111122 } else {
0 commit comments