Skip to content

Commit

Permalink
fix: linkify text nodes without whitespace padding
Browse files Browse the repository at this point in the history
Closes #275
  • Loading branch information
lidel committed Sep 12, 2017
1 parent 3b5ed39 commit fa673ea
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions add-on/src/lib/linkifyDOM.js
Expand Up @@ -17,7 +17,7 @@
// linkify lock
window.ipfsLinkifiedDOM = true

const urlRE = /\s+(?:\/ip(f|n)s\/|fs:|ipns:|ipfs:)[^\s+"<>]+/g
const urlRE = /(?:\s+|^)(?:\/ip(f|n)s\/|fs:|ipns:|ipfs:)[^\s+"<>]+/g

// tags we will scan looking for un-hyperlinked IPFS addresses
const allowedParents = [
Expand Down Expand Up @@ -56,6 +56,7 @@
})

function linkifyContainer (container) {
// console.log('linkifyContainer', container)
if (!container.nodeType) {
return
}
Expand Down Expand Up @@ -85,7 +86,7 @@
}

function normalizeHref (href) {
console.log(href)
// console.log(href)
// convert various variants to regular URL at the public gateway
if (href.startsWith('ipfs:')) {
href = href.replace('ipfs:', '/ipfs/')
Expand All @@ -102,6 +103,7 @@
}

function linkifyTextNode (node) {
// console.log('linkifyTextNode', node)
let link
let match
const txt = node.textContent
Expand Down

0 comments on commit fa673ea

Please sign in to comment.