@@ -27,9 +27,9 @@ export class DSONameService {
2727 * With only two exceptions those solutions seem overkill for now.
2828 */
2929 private readonly factories = {
30- EPerson : ( dso : DSpaceObject , injectedAsHTML ?: boolean ) : string => {
31- const firstName = dso . firstMetadataValue ( 'eperson.firstname' , undefined , injectedAsHTML ) ;
32- const lastName = dso . firstMetadataValue ( 'eperson.lastname' , undefined , injectedAsHTML ) ;
30+ EPerson : ( dso : DSpaceObject , escapeHTML ?: boolean ) : string => {
31+ const firstName = dso . firstMetadataValue ( 'eperson.firstname' , undefined , escapeHTML ) ;
32+ const lastName = dso . firstMetadataValue ( 'eperson.lastname' , undefined , escapeHTML ) ;
3333 if ( isEmpty ( firstName ) && isEmpty ( lastName ) ) {
3434 return this . translateService . instant ( 'dso.name.unnamed' ) ;
3535 } else if ( isEmpty ( firstName ) || isEmpty ( lastName ) ) {
@@ -38,33 +38,33 @@ export class DSONameService {
3838 return `${ firstName } ${ lastName } ` ;
3939 }
4040 } ,
41- Person : ( dso : DSpaceObject , injectedAsHTML ?: boolean ) : string => {
42- const familyName = dso . firstMetadataValue ( 'person.familyName' , undefined , injectedAsHTML ) ;
43- const givenName = dso . firstMetadataValue ( 'person.givenName' , undefined , injectedAsHTML ) ;
41+ Person : ( dso : DSpaceObject , escapeHTML ?: boolean ) : string => {
42+ const familyName = dso . firstMetadataValue ( 'person.familyName' , undefined , escapeHTML ) ;
43+ const givenName = dso . firstMetadataValue ( 'person.givenName' , undefined , escapeHTML ) ;
4444 if ( isEmpty ( familyName ) && isEmpty ( givenName ) ) {
45- return dso . firstMetadataValue ( 'dc.title' , undefined , injectedAsHTML ) || this . translateService . instant ( 'dso.name.unnamed' ) ;
45+ return dso . firstMetadataValue ( 'dc.title' , undefined , escapeHTML ) || this . translateService . instant ( 'dso.name.unnamed' ) ;
4646 } else if ( isEmpty ( familyName ) || isEmpty ( givenName ) ) {
4747 return familyName || givenName ;
4848 } else {
4949 return `${ familyName } , ${ givenName } ` ;
5050 }
5151 } ,
52- OrgUnit : ( dso : DSpaceObject , injectedAsHTML ?: boolean ) : string => {
53- return dso . firstMetadataValue ( 'organization.legalName' , undefined , injectedAsHTML ) || this . translateService . instant ( 'dso.name.untitled' ) ;
52+ OrgUnit : ( dso : DSpaceObject , escapeHTML ?: boolean ) : string => {
53+ return dso . firstMetadataValue ( 'organization.legalName' , undefined , escapeHTML ) ;
5454 } ,
55- Default : ( dso : DSpaceObject , injectedAsHTML ?: boolean ) : string => {
55+ Default : ( dso : DSpaceObject , escapeHTML ?: boolean ) : string => {
5656 // If object doesn't have dc.title metadata use name property
57- return dso . firstMetadataValue ( 'dc.title' , undefined , injectedAsHTML ) || dso . name || this . translateService . instant ( 'dso.name.untitled' ) ;
58- }
57+ return dso . firstMetadataValue ( 'dc.title' , undefined , escapeHTML ) || dso . name || this . translateService . instant ( 'dso.name.untitled' ) ;
58+ } ,
5959 } ;
6060
6161 /**
6262 * Get the name for the given {@link DSpaceObject}
6363 *
6464 * @param dso The {@link DSpaceObject} you want a name for
65- * @param injectedAsHTML Whether the HTML is used inside a `[innerHTML]` attribute
65+ * @param escapeHTML Whether the HTML is used inside a `[innerHTML]` attribute
6666 */
67- getName ( dso : DSpaceObject | undefined , injectedAsHTML ?: boolean ) : string {
67+ getName ( dso : DSpaceObject | undefined , escapeHTML ?: boolean ) : string {
6868 if ( dso ) {
6969 const types = dso . getRenderTypes ( ) ;
7070 const match = types
@@ -73,10 +73,10 @@ export class DSONameService {
7373
7474 let name ;
7575 if ( hasValue ( match ) ) {
76- name = this . factories [ match ] ( dso , injectedAsHTML ) ;
76+ name = this . factories [ match ] ( dso , escapeHTML ) ;
7777 }
7878 if ( isEmpty ( name ) ) {
79- name = this . factories . Default ( dso , injectedAsHTML ) ;
79+ name = this . factories . Default ( dso , escapeHTML ) ;
8080 }
8181 return name ;
8282 } else {
@@ -89,28 +89,28 @@ export class DSONameService {
8989 *
9090 * @param object
9191 * @param dso
92- * @param injectedAsHTML Whether the HTML is used inside a `[innerHTML]` attribute
92+ * @param escapeHTML Whether the HTML is used inside a `[innerHTML]` attribute
9393 *
9494 * @returns {string } html embedded hit highlight.
9595 */
96- getHitHighlights ( object : any , dso : DSpaceObject , injectedAsHTML ?: boolean ) : string {
96+ getHitHighlights ( object : any , dso : DSpaceObject , escapeHTML ?: boolean ) : string {
9797 const types = dso . getRenderTypes ( ) ;
9898 const entityType = types
9999 . filter ( ( type ) => typeof type === 'string' )
100100 . find ( ( type : string ) => ( [ 'Person' , 'OrgUnit' ] ) . includes ( type ) ) as string ;
101101 if ( entityType === 'Person' ) {
102- const familyName = this . firstMetadataValue ( object , dso , 'person.familyName' , injectedAsHTML ) ;
103- const givenName = this . firstMetadataValue ( object , dso , 'person.givenName' , injectedAsHTML ) ;
102+ const familyName = this . firstMetadataValue ( object , dso , 'person.familyName' , escapeHTML ) ;
103+ const givenName = this . firstMetadataValue ( object , dso , 'person.givenName' , escapeHTML ) ;
104104 if ( isEmpty ( familyName ) && isEmpty ( givenName ) ) {
105- return this . firstMetadataValue ( object , dso , 'dc.title' , injectedAsHTML ) || dso . name ;
105+ return this . firstMetadataValue ( object , dso , 'dc.title' , escapeHTML ) || dso . name ;
106106 } else if ( isEmpty ( familyName ) || isEmpty ( givenName ) ) {
107107 return familyName || givenName ;
108108 }
109109 return `${ familyName } , ${ givenName } ` ;
110110 } else if ( entityType === 'OrgUnit' ) {
111- return this . firstMetadataValue ( object , dso , 'organization.legalName' , injectedAsHTML ) || this . translateService . instant ( 'dso.name.untitled' ) ;
111+ return this . firstMetadataValue ( object , dso , 'organization.legalName' , escapeHTML ) ;
112112 }
113- return this . firstMetadataValue ( object , dso , 'dc.title' , injectedAsHTML ) || dso . name || this . translateService . instant ( 'dso.name.untitled' ) ;
113+ return this . firstMetadataValue ( object , dso , 'dc.title' , escapeHTML ) || dso . name || this . translateService . instant ( 'dso.name.untitled' ) ;
114114 }
115115
116116 /**
@@ -119,12 +119,12 @@ export class DSONameService {
119119 * @param object
120120 * @param dso
121121 * @param {string|string[] } keyOrKeys The metadata key(s) in scope. Wildcards are supported; see [[Metadata]].
122- * @param injectedAsHTML Whether the HTML is used inside a `[innerHTML]` attribute
122+ * @param escapeHTML Whether the HTML is used inside a `[innerHTML]` attribute
123123 *
124124 * @returns {string } the first matching string value, or `undefined`.
125125 */
126- firstMetadataValue ( object : any , dso : DSpaceObject , keyOrKeys : string | string [ ] , injectedAsHTML ?: boolean ) : string {
127- return Metadata . firstValue ( dso . metadata , keyOrKeys , object . hitHighlights , undefined , injectedAsHTML ) ;
126+ firstMetadataValue ( object : any , dso : DSpaceObject , keyOrKeys : string | string [ ] , escapeHTML ?: boolean ) : string {
127+ return Metadata . firstValue ( dso . metadata , keyOrKeys , object . hitHighlights , undefined , escapeHTML ) ;
128128 }
129129
130130}
0 commit comments