fix: quote image license text (closes #549)

This commit is contained in:
Isaac 2024-01-01 16:41:06 +00:00
parent c29376f715
commit a7069fbf1e
No known key found for this signature in database
GPG Key ID: 0DE40AE37BBA5C33
1 changed files with 6 additions and 1 deletions

View File

@ -113,6 +113,11 @@ export default class Quote extends PureComponent {
.join('_')}`;
}
stripHTML(html) {
const tmpdoc = new DOMParser().parseFromString(html, 'text/html');
return tmpdoc.body.textContent || "";
}
async getAuthorImg(author) {
if (localStorage.getItem('authorImg') === 'false') {
return {
@ -150,7 +155,7 @@ export default class Quote extends PureComponent {
const license = metadata.LicenseShortName;
const photographer =
metadata.Attribution.value ||
metadata.Artist?.value.match(/<a.+>(?<name>.+)<\/a>/i)?.groups.name ||
this.stripHTML(metadata.Artist?.value || '').replace(/ \(talk\)/, '') || // talk page link (if applicable) is only removed for English
'Unknown';
authorimglicense = `© ${photographer}. ${license.value}`;
authorimglicense = authorimglicense.replace(/copyright\s/i, '').replace(/©\s©\s/, '© ');