Skip to content

Commit a543213

Browse files
authored
Merge pull request #61 from couchbase/codeblock-functionality
Prevent $ from being copied to clipboard
2 parents a44550b + 885362b commit a543213

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/js/07-copy-to-clipboard.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@
2929
// NOTE: ignore event on pseudo-element
3030
if (e.currentTarget === e.target) return
3131
var bashText = codeBlock.innerText
32-
// bashText.slice(2)
3332
// remove '$' from copy to code functionality in code block console
34-
var spliceData = bashText.split('$').join('')
35-
if (codeBlock.dataset.lang === 'console' || bashText.includes('$')) {
33+
// var spliceData = bashText.split('$').join('')
34+
var check = bashText.charAt(0)
35+
if (check === '$') {
36+
var spliceData = bashText.substring(2)
3637
navigator.clipboard.writeText(spliceData).then(
3738
function () {
3839
/* Chrome doesn't seem to blur automatically,

0 commit comments

Comments
 (0)