@@ -31,9 +31,9 @@ export class DSONameService {
3131 * With only two exceptions those solutions seem overkill for now.
3232 */
3333 private readonly factories = {
34- EPerson : ( dso : DSpaceObject , injectedAsHTML ?: boolean ) : string => {
35- const firstName = dso . firstMetadataValue ( 'eperson.firstname' , undefined , injectedAsHTML ) ;
36- const lastName = dso . firstMetadataValue ( 'eperson.lastname' , undefined , injectedAsHTML ) ;
34+ EPerson : ( dso : DSpaceObject , escapeHTML ?: boolean ) : string => {
35+ const firstName = dso . firstMetadataValue ( 'eperson.firstname' , undefined , escapeHTML ) ;
36+ const lastName = dso . firstMetadataValue ( 'eperson.lastname' , undefined , escapeHTML ) ;
3737 if ( isEmpty ( firstName ) && isEmpty ( lastName ) ) {
3838 return this . translateService . instant ( 'dso.name.unnamed' ) ;
3939 } else if ( isEmpty ( firstName ) || isEmpty ( lastName ) ) {
@@ -42,33 +42,33 @@ export class DSONameService {
4242 return `${ firstName } ${ lastName } ` ;
4343 }
4444 } ,
45- Person : ( dso : DSpaceObject , injectedAsHTML ?: boolean ) : string => {
46- const familyName = dso . firstMetadataValue ( 'person.familyName' , undefined , injectedAsHTML ) ;
47- const givenName = dso . firstMetadataValue ( 'person.givenName' , undefined , injectedAsHTML ) ;
45+ Person : ( dso : DSpaceObject , escapeHTML ?: boolean ) : string => {
46+ const familyName = dso . firstMetadataValue ( 'person.familyName' , undefined , escapeHTML ) ;
47+ const givenName = dso . firstMetadataValue ( 'person.givenName' , undefined , escapeHTML ) ;
4848 if ( isEmpty ( familyName ) && isEmpty ( givenName ) ) {
49- return dso . firstMetadataValue ( 'dc.title' , undefined , injectedAsHTML ) || this . translateService . instant ( 'dso.name.unnamed' ) ;
49+ return dso . firstMetadataValue ( 'dc.title' , undefined , escapeHTML ) || this . translateService . instant ( 'dso.name.unnamed' ) ;
5050 } else if ( isEmpty ( familyName ) || isEmpty ( givenName ) ) {
5151 return familyName || givenName ;
5252 } else {
5353 return `${ familyName } , ${ givenName } ` ;
5454 }
5555 } ,
56- OrgUnit : ( dso : DSpaceObject , injectedAsHTML ?: boolean ) : string => {
57- return dso . firstMetadataValue ( 'organization.legalName' , undefined , injectedAsHTML ) ;
56+ OrgUnit : ( dso : DSpaceObject , escapeHTML ?: boolean ) : string => {
57+ return dso . firstMetadataValue ( 'organization.legalName' , undefined , escapeHTML ) ;
5858 } ,
59- Default : ( dso : DSpaceObject , injectedAsHTML ?: boolean ) : string => {
59+ Default : ( dso : DSpaceObject , escapeHTML ?: boolean ) : string => {
6060 // If object doesn't have dc.title metadata use name property
61- return dso . firstMetadataValue ( 'dc.title' , undefined , injectedAsHTML ) || dso . name || this . translateService . instant ( 'dso.name.untitled' ) ;
61+ return dso . firstMetadataValue ( 'dc.title' , undefined , escapeHTML ) || dso . name || this . translateService . instant ( 'dso.name.untitled' ) ;
6262 } ,
6363 } ;
6464
6565 /**
6666 * Get the name for the given {@link DSpaceObject}
6767 *
6868 * @param dso The {@link DSpaceObject} you want a name for
69- * @param injectedAsHTML Whether the HTML is used inside a `[innerHTML]` attribute
69+ * @param escapeHTML Whether the HTML is used inside a `[innerHTML]` attribute
7070 */
71- getName ( dso : DSpaceObject | undefined , injectedAsHTML ?: boolean ) : string {
71+ getName ( dso : DSpaceObject | undefined , escapeHTML ?: boolean ) : string {
7272 if ( dso ) {
7373 const types = dso . getRenderTypes ( ) ;
7474 const match = types
@@ -77,10 +77,10 @@ export class DSONameService {
7777
7878 let name ;
7979 if ( hasValue ( match ) ) {
80- name = this . factories [ match ] ( dso , injectedAsHTML ) ;
80+ name = this . factories [ match ] ( dso , escapeHTML ) ;
8181 }
8282 if ( isEmpty ( name ) ) {
83- name = this . factories . Default ( dso , injectedAsHTML ) ;
83+ name = this . factories . Default ( dso , escapeHTML ) ;
8484 }
8585 return name ;
8686 } else {
@@ -93,28 +93,28 @@ export class DSONameService {
9393 *
9494 * @param object
9595 * @param dso
96- * @param injectedAsHTML Whether the HTML is used inside a `[innerHTML]` attribute
96+ * @param escapeHTML Whether the HTML is used inside a `[innerHTML]` attribute
9797 *
9898 * @returns {string } html embedded hit highlight.
9999 */
100- getHitHighlights ( object : any , dso : DSpaceObject , injectedAsHTML ?: boolean ) : string {
100+ getHitHighlights ( object : any , dso : DSpaceObject , escapeHTML ?: boolean ) : string {
101101 const types = dso . getRenderTypes ( ) ;
102102 const entityType = types
103103 . filter ( ( type ) => typeof type === 'string' )
104104 . find ( ( type : string ) => ( [ 'Person' , 'OrgUnit' ] ) . includes ( type ) ) as string ;
105105 if ( entityType === 'Person' ) {
106- const familyName = this . firstMetadataValue ( object , dso , 'person.familyName' , injectedAsHTML ) ;
107- const givenName = this . firstMetadataValue ( object , dso , 'person.givenName' , injectedAsHTML ) ;
106+ const familyName = this . firstMetadataValue ( object , dso , 'person.familyName' , escapeHTML ) ;
107+ const givenName = this . firstMetadataValue ( object , dso , 'person.givenName' , escapeHTML ) ;
108108 if ( isEmpty ( familyName ) && isEmpty ( givenName ) ) {
109- return this . firstMetadataValue ( object , dso , 'dc.title' , injectedAsHTML ) || dso . name ;
109+ return this . firstMetadataValue ( object , dso , 'dc.title' , escapeHTML ) || dso . name ;
110110 } else if ( isEmpty ( familyName ) || isEmpty ( givenName ) ) {
111111 return familyName || givenName ;
112112 }
113113 return `${ familyName } , ${ givenName } ` ;
114114 } else if ( entityType === 'OrgUnit' ) {
115- return this . firstMetadataValue ( object , dso , 'organization.legalName' , injectedAsHTML ) ;
115+ return this . firstMetadataValue ( object , dso , 'organization.legalName' , escapeHTML ) ;
116116 }
117- return this . firstMetadataValue ( object , dso , 'dc.title' , injectedAsHTML ) || dso . name || this . translateService . instant ( 'dso.name.untitled' ) ;
117+ return this . firstMetadataValue ( object , dso , 'dc.title' , escapeHTML ) || dso . name || this . translateService . instant ( 'dso.name.untitled' ) ;
118118 }
119119
120120 /**
@@ -123,12 +123,12 @@ export class DSONameService {
123123 * @param object
124124 * @param dso
125125 * @param {string|string[] } keyOrKeys The metadata key(s) in scope. Wildcards are supported; see [[Metadata]].
126- * @param injectedAsHTML Whether the HTML is used inside a `[innerHTML]` attribute
126+ * @param escapeHTML Whether the HTML is used inside a `[innerHTML]` attribute
127127 *
128128 * @returns {string } the first matching string value, or `undefined`.
129129 */
130- firstMetadataValue ( object : any , dso : DSpaceObject , keyOrKeys : string | string [ ] , injectedAsHTML ?: boolean ) : string {
131- return Metadata . firstValue ( dso . metadata , keyOrKeys , object . hitHighlights , undefined , injectedAsHTML ) ;
130+ firstMetadataValue ( object : any , dso : DSpaceObject , keyOrKeys : string | string [ ] , escapeHTML ?: boolean ) : string {
131+ return Metadata . firstValue ( dso . metadata , keyOrKeys , object . hitHighlights , undefined , escapeHTML ) ;
132132 }
133133
134134}
0 commit comments