Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: removed the escaping of the name of sidebar #991

Merged
merged 1 commit into from
Dec 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions src/core/render/tpl.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {isMobile} from '../util/env'
import {escapeString} from '../util/core'
import { isMobile } from '../util/env'
/**
* Render github corner
* @param {Object} data
Expand All @@ -9,11 +8,13 @@ export function corner(data, cornerExternalLinkTarge) {
if (!data) {
return ''
}

if (!/\/\//.test(data)) {
data = 'https://github.com/' + data
}

data = data.replace(/^git\+/, '')
// double check
// Double check
cornerExternalLinkTarge = cornerExternalLinkTarge || '_blank'

return (
Expand All @@ -31,8 +32,7 @@ export function corner(data, cornerExternalLinkTarge) {
* Render main content
*/
export function main(config) {

const name = config.name? escapeString(config.name):''
const name = config.name ? config.name : ''

const aside =
'<button class="sidebar-toggle" aria-label="Menu">' +
Expand All @@ -41,13 +41,11 @@ export function main(config) {
'</div>' +
'</button>' +
'<aside class="sidebar">' +
(config.name ?
`<h1 class="app-name"><a class="app-name-link" data-nosearch>${
config.logo ?
`<img alt="${name}" src=${config.logo}>` :
name
}</a></h1>` :
'') +
(config.name
? `<h1 class="app-name"><a class="app-name-link" data-nosearch>${
config.logo ? `<img alt="${name}" src=${config.logo}>` : name
}</a></h1>`
: '') +
'<div class="sidebar-nav"><!--sidebar--></div>' +
'</aside>'

Expand Down Expand Up @@ -88,6 +86,7 @@ export function tree(toc, tpl = '<ul class="app-sub-sidebar">{inner}</ul>') {
if (!toc || !toc.length) {
return ''
}

let innerHTML = ''
toc.forEach(node => {
innerHTML += `<li><a class="section-link" href="${node.slug}">${node.title}</a></li>`
Expand Down
15 changes: 0 additions & 15 deletions src/core/util/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,3 @@ 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])
}