Skip to content

Commit

Permalink
fix for #636 escape special charaters (#637)
Browse files Browse the repository at this point in the history
  • Loading branch information
JabSYsEmb committed Jul 17, 2024
1 parent 70baf7d commit f38872e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/utilities/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,22 @@ export const nodeKey = node => {

export const createClassname = (el, ellipse = false) => {
if (!el.className) return ''

const combined = Array.from(el.classList).reduce((classnames, classname) =>
classnames += '.' + classname
classnames += '.' + escapeSpecialCharacters(classname)
, '')

return ellipse && combined.length > 30
? combined.substring(0,30) + '...'
: combined
}

const escapeSpecialCharacters = (query) =>
Array.from(query)
.map((char) => /[0-9a-zA-Z_\s-]/.test(char) ? char : `\\${char}`)
.join("")


export const metaKey = window.navigator.platform.includes('Mac')
? 'cmd'
: 'ctrl'
Expand Down

0 comments on commit f38872e

Please sign in to comment.