Skip to content

Commit 02c7fe9

Browse files
134319: Renamed injectedAsHTML to escapeHTML
1 parent 0f8f0c6 commit 02c7fe9

File tree

6 files changed

+68
-68
lines changed

6 files changed

+68
-68
lines changed

src/app/core/breadcrumbs/dso-name.service.ts

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

src/app/core/shared/dspace-object.model.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,47 +119,47 @@ export class DSpaceObject extends ListableObject implements CacheableObject {
119119
*
120120
* @param {string|string[]} keyOrKeys The metadata key(s) in scope. Wildcards are supported; see [[Metadata]].
121121
* @param {MetadataValueFilter} valueFilter The value filter to use. If unspecified, no filtering will be done.
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
* @returns {MetadataValue[]} the matching values or an empty array.
124124
*/
125-
allMetadata(keyOrKeys: string | string[], valueFilter?: MetadataValueFilter, injectedAsHTML?: boolean): MetadataValue[] {
126-
return Metadata.all(this.metadata, keyOrKeys, undefined, valueFilter, injectedAsHTML);
125+
allMetadata(keyOrKeys: string | string[], valueFilter?: MetadataValueFilter, escapeHTML?: boolean): MetadataValue[] {
126+
return Metadata.all(this.metadata, keyOrKeys, undefined, valueFilter, escapeHTML);
127127
}
128128

129129
/**
130130
* Like [[allMetadata]], but only returns string values.
131131
*
132132
* @param {string|string[]} keyOrKeys The metadata key(s) in scope. Wildcards are supported; see [[Metadata]].
133133
* @param {MetadataValueFilter} valueFilter The value filter to use. If unspecified, no filtering will be done.
134-
* @param injectedAsHTML Whether the HTML is used inside a `[innerHTML]` attribute
134+
* @param escapeHTML Whether the HTML is used inside a `[innerHTML]` attribute
135135
* @returns {string[]} the matching string values or an empty array.
136136
*/
137-
allMetadataValues(keyOrKeys: string | string[], valueFilter?: MetadataValueFilter, injectedAsHTML?: boolean): string[] {
138-
return Metadata.allValues(this.metadata, keyOrKeys, undefined, valueFilter, injectedAsHTML);
137+
allMetadataValues(keyOrKeys: string | string[], valueFilter?: MetadataValueFilter, escapeHTML?: boolean): string[] {
138+
return Metadata.allValues(this.metadata, keyOrKeys, undefined, valueFilter, escapeHTML);
139139
}
140140

141141
/**
142142
* Gets the first matching MetadataValue object in this DSpaceObject, or `undefined`.
143143
*
144144
* @param {string|string[]} keyOrKeys The metadata key(s) in scope. Wildcards are supported; see [[Metadata]].
145145
* @param {MetadataValueFilter} valueFilter The value filter to use. If unspecified, no filtering will be done.
146-
* @param injectedAsHTML Whether the HTML is used inside a `[innerHTML]` attribute
146+
* @param escapeHTML Whether the HTML is used inside a `[innerHTML]` attribute
147147
* @returns {MetadataValue} the first matching value, or `undefined`.
148148
*/
149-
firstMetadata(keyOrKeys: string | string[], valueFilter?: MetadataValueFilter, injectedAsHTML?: boolean): MetadataValue {
150-
return Metadata.first(this.metadata, keyOrKeys, undefined, valueFilter, injectedAsHTML);
149+
firstMetadata(keyOrKeys: string | string[], valueFilter?: MetadataValueFilter, escapeHTML?: boolean): MetadataValue {
150+
return Metadata.first(this.metadata, keyOrKeys, undefined, valueFilter, escapeHTML);
151151
}
152152

153153
/**
154154
* Like [[firstMetadata]], but only returns a string value, or `undefined`.
155155
*
156156
* @param {string|string[]} keyOrKeys The metadata key(s) in scope. Wildcards are supported; see [[Metadata]].
157157
* @param {MetadataValueFilter} valueFilter The value filter to use. If unspecified, no filtering will be done.
158-
* @param injectedAsHTML Whether the HTML is used inside a `[innerHTML]` attribute
158+
* @param escapeHTML Whether the HTML is used inside a `[innerHTML]` attribute
159159
* @returns {string} the first matching string value, or `undefined`.
160160
*/
161-
firstMetadataValue(keyOrKeys: string | string[], valueFilter?: MetadataValueFilter, injectedAsHTML?: boolean): string {
162-
return Metadata.firstValue(this.metadata, keyOrKeys, undefined, valueFilter, injectedAsHTML);
161+
firstMetadataValue(keyOrKeys: string | string[], valueFilter?: MetadataValueFilter, escapeHTML?: boolean): string {
162+
return Metadata.firstValue(this.metadata, keyOrKeys, undefined, valueFilter, escapeHTML);
163163
}
164164

165165
/**

src/app/core/shared/metadata.utils.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ export class Metadata {
3636
* @param {string|string[]} keyOrKeys The metadata key(s) in scope. Wildcards are supported; see above.
3737
* @param hitHighlights The search hit highlights.
3838
* @param {MetadataValueFilter} filter The value filter to use. If unspecified, no filtering will be done.
39-
* @param injectedAsHTML Whether the HTML is used inside a `[innerHTML]` attribute
39+
* @param escapeHTML Whether the HTML is used inside a `[innerHTML]` attribute
4040
* @returns {MetadataValue[]} the matching values or an empty array.
4141
*/
42-
public static all(metadata: MetadataMapInterface, keyOrKeys: string | string[], hitHighlights?: MetadataMapInterface, filter?: MetadataValueFilter, injectedAsHTML?: boolean): MetadataValue[] {
42+
public static all(metadata: MetadataMapInterface, keyOrKeys: string | string[], hitHighlights?: MetadataMapInterface, filter?: MetadataValueFilter, escapeHTML?: boolean): MetadataValue[] {
4343
const matches: MetadataValue[] = [];
4444
if (isNotEmpty(hitHighlights)) {
4545
for (const mdKey of Metadata.resolveKeys(hitHighlights, keyOrKeys)) {
@@ -59,7 +59,7 @@ export class Metadata {
5959
if (metadata[mdKey]) {
6060
for (const candidate of metadata[mdKey]) {
6161
if (Metadata.valueMatches(candidate as MetadataValue, filter)) {
62-
if (injectedAsHTML) {
62+
if (escapeHTML) {
6363
matches.push(Object.assign(new MetadataValue(), candidate, {
6464
value: escape(candidate.value),
6565
}));
@@ -80,11 +80,11 @@ export class Metadata {
8080
* @param {string|string[]} keyOrKeys The metadata key(s) in scope. Wildcards are supported; see above.
8181
* @param hitHighlights The search hit highlights.
8282
* @param {MetadataValueFilter} filter The value filter to use. If unspecified, no filtering will be done.
83-
* @param injectedAsHTML Whether the HTML is used inside a `[innerHTML]` attribute
83+
* @param escapeHTML Whether the HTML is used inside a `[innerHTML]` attribute
8484
* @returns {string[]} the matching string values or an empty array.
8585
*/
86-
public static allValues(metadata: MetadataMapInterface, keyOrKeys: string | string[], hitHighlights?: MetadataMapInterface, filter?: MetadataValueFilter, injectedAsHTML?: boolean): string[] {
87-
return Metadata.all(metadata, keyOrKeys, hitHighlights, filter, injectedAsHTML).map((mdValue) => mdValue.value);
86+
public static allValues(metadata: MetadataMapInterface, keyOrKeys: string | string[], hitHighlights?: MetadataMapInterface, filter?: MetadataValueFilter, escapeHTML?: boolean): string[] {
87+
return Metadata.all(metadata, keyOrKeys, hitHighlights, filter, escapeHTML).map((mdValue) => mdValue.value);
8888
}
8989

9090
/**
@@ -94,10 +94,10 @@ export class Metadata {
9494
* @param {string|string[]} keyOrKeys The metadata key(s) in scope. Wildcards are supported; see above.
9595
* @param hitHighlights The search hit highlights.
9696
* @param {MetadataValueFilter} filter The value filter to use. If unspecified, no filtering will be done.
97-
* @param injectedAsHTML Whether the HTML is used inside a `[innerHTML]` attribute
97+
* @param escapeHTML Whether the HTML is used inside a `[innerHTML]` attribute
9898
* @returns {MetadataValue} the first matching value, or `undefined`.
9999
*/
100-
public static first(metadata: MetadataMapInterface, keyOrKeys: string | string[], hitHighlights?: MetadataMapInterface, filter?: MetadataValueFilter, injectedAsHTML?: boolean): MetadataValue {
100+
public static first(metadata: MetadataMapInterface, keyOrKeys: string | string[], hitHighlights?: MetadataMapInterface, filter?: MetadataValueFilter, escapeHTML?: boolean): MetadataValue {
101101
if (isNotEmpty(hitHighlights)) {
102102
for (const key of Metadata.resolveKeys(hitHighlights, keyOrKeys)) {
103103
const values: MetadataValue[] = hitHighlights[key] as MetadataValue[];
@@ -110,7 +110,7 @@ export class Metadata {
110110
const values: MetadataValue[] = metadata[key] as MetadataValue[];
111111
if (values) {
112112
const result: MetadataValue = values.find((value: MetadataValue) => Metadata.valueMatches(value, filter));
113-
if (injectedAsHTML) {
113+
if (escapeHTML) {
114114
return Object.assign(new MetadataValue(), result, {
115115
value: escape(result.value),
116116
});
@@ -127,11 +127,11 @@ export class Metadata {
127127
* @param {string|string[]} keyOrKeys The metadata key(s) in scope. Wildcards are supported; see above.
128128
* @param hitHighlights The search hit highlights.
129129
* @param {MetadataValueFilter} filter The value filter to use. If unspecified, no filtering will be done.
130-
* @param injectedAsHTML Whether the HTML is used inside a `[innerHTML]` attribute
130+
* @param escapeHTML Whether the HTML is used inside a `[innerHTML]` attribute
131131
* @returns {string} the first matching string value, or `undefined`.
132132
*/
133-
public static firstValue(metadata: MetadataMapInterface, keyOrKeys: string | string[], hitHighlights?: MetadataMapInterface, filter?: MetadataValueFilter, injectedAsHTML?: boolean): string {
134-
const value = Metadata.first(metadata, keyOrKeys, hitHighlights, filter, injectedAsHTML);
133+
public static firstValue(metadata: MetadataMapInterface, keyOrKeys: string | string[], hitHighlights?: MetadataMapInterface, filter?: MetadataValueFilter, escapeHTML?: boolean): string {
134+
const value = Metadata.first(metadata, keyOrKeys, hitHighlights, filter, escapeHTML);
135135
return isUndefined(value) ? undefined : value.value;
136136
}
137137

src/app/shared/object-detail/my-dspace-result-detail-element/search-result-detail-element.component.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,21 @@ export class SearchResultDetailElementComponent<T extends SearchResult<K>, K ext
3737
* Gets all matching metadata string values from hitHighlights or dso metadata, preferring hitHighlights.
3838
*
3939
* @param {string|string[]} keyOrKeys The metadata key(s) in scope. Wildcards are supported; see [[Metadata]].
40-
* @param injectedAsHTML Whether the HTML is used inside a `[innerHTML]` attribute
40+
* @param escapeHTML Whether the HTML is used inside a `[innerHTML]` attribute
4141
* @returns {string[]} the matching string values or an empty array.
4242
*/
43-
allMetadataValues(keyOrKeys: string | string[], injectedAsHTML = true): string[] {
44-
return Metadata.allValues(this.dso.metadata, keyOrKeys, this.object.hitHighlights, undefined, injectedAsHTML);
43+
allMetadataValues(keyOrKeys: string | string[], escapeHTML = true): string[] {
44+
return Metadata.allValues(this.dso.metadata, keyOrKeys, this.object.hitHighlights, undefined, escapeHTML);
4545
}
4646

4747
/**
4848
* Gets the first matching metadata string value from hitHighlights or dso metadata, preferring hitHighlights.
4949
*
5050
* @param {string|string[]} keyOrKeys The metadata key(s) in scope. Wildcards are supported; see [[Metadata]].
51-
* @param injectedAsHTML Whether the HTML is used inside a `[innerHTML]` attribute
51+
* @param escapeHTML Whether the HTML is used inside a `[innerHTML]` attribute
5252
* @returns {string} the first matching string value, or `undefined`.
5353
*/
54-
firstMetadataValue(keyOrKeys: string | string[], injectedAsHTML = true): string {
55-
return Metadata.firstValue(this.dso.metadata, keyOrKeys, this.object.hitHighlights, undefined, injectedAsHTML);
54+
firstMetadataValue(keyOrKeys: string | string[], escapeHTML = true): string {
55+
return Metadata.firstValue(this.dso.metadata, keyOrKeys, this.object.hitHighlights, undefined, escapeHTML);
5656
}
5757
}

src/app/shared/object-grid/search-result-grid-element/search-result-grid-element.component.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,22 @@ export class SearchResultGridElementComponent<T extends SearchResult<K>, K exten
5151
* Gets all matching metadata string values from hitHighlights or dso metadata, preferring hitHighlights.
5252
*
5353
* @param {string|string[]} keyOrKeys The metadata key(s) in scope. Wildcards are supported; see [[Metadata]].
54-
* @param injectedAsHTML Whether the HTML is used inside a `[innerHTML]` attribute
54+
* @param escapeHTML Whether the HTML is used inside a `[innerHTML]` attribute
5555
* @returns {string[]} the matching string values or an empty array.
5656
*/
57-
allMetadataValues(keyOrKeys: string | string[], injectedAsHTML = true): string[] {
58-
return Metadata.allValues(this.dso.metadata, keyOrKeys, this.object.hitHighlights, undefined, injectedAsHTML);
57+
allMetadataValues(keyOrKeys: string | string[], escapeHTML = true): string[] {
58+
return Metadata.allValues(this.dso.metadata, keyOrKeys, this.object.hitHighlights, undefined, escapeHTML);
5959
}
6060

6161
/**
6262
* Gets the first matching metadata string value from hitHighlights or dso metadata, preferring hitHighlights.
6363
*
6464
* @param {string|string[]} keyOrKeys The metadata key(s) in scope. Wildcards are supported; see [[Metadata]].
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
* @returns {string} the first matching string value, or `undefined`.
6767
*/
68-
firstMetadataValue(keyOrKeys: string | string[], injectedAsHTML = true): string {
69-
return Metadata.firstValue(this.dso.metadata, keyOrKeys, this.object.hitHighlights, undefined, injectedAsHTML);
68+
firstMetadataValue(keyOrKeys: string | string[], escapeHTML = true): string {
69+
return Metadata.firstValue(this.dso.metadata, keyOrKeys, this.object.hitHighlights, undefined, escapeHTML);
7070
}
7171

7272
private isCollapsed(): Observable<boolean> {

0 commit comments

Comments
 (0)