Merge pull request #974 from Koooooo-7/develop

[fix]#972 when 'logo' is set, 'name' is not set correctly inside the 'alt' as same as without 'logo' set.
This commit is contained in:
Anix 2019-12-11 13:54:31 +05:30 committed by GitHub
commit 1622578045
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 3 deletions

View File

@ -1,4 +1,5 @@
import {isMobile} from '../util/env'
import {escapeString} from '../util/core'
/**
* Render github corner
* @param {Object} data
@ -30,6 +31,9 @@ export function corner(data, cornerExternalLinkTarge) {
* Render main content
*/
export function main(config) {
const name = config.name? escapeString(config.name):''
const aside =
'<button class="sidebar-toggle" aria-label="Menu">' +
'<div class="sidebar-toggle-button">' +
@ -39,9 +43,9 @@ export function main(config) {
'<aside class="sidebar">' +
(config.name ?
`<h1 class="app-name"><a class="app-name-link" data-nosearch>${
config.logo ?
`<img alt=${config.name} src=${config.logo}>` :
config.name
config.logo ?
`<img alt="${name}" src=${config.logo}>` :
name
}</a></h1>` :
'') +
'<div class="sidebar-nav"><!--sidebar--></div>' +

View File

@ -56,3 +56,19 @@ export function noop() {}
export function isFn(obj) {
return typeof obj === 'function'
}
/**
* escape String
*/
export function escapeString(string) {
const entityMap = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
'\'': '&#39;',
'/': '&#x2F;'
}
return String(string).replace(/[&<>"'/]/g, s => entityMap[s])
}