From 9b998a6318dbf0851559a06dd0b45f88fc954ac9 Mon Sep 17 00:00:00 2001 From: Dan Date: Sat, 16 Dec 2017 22:44:22 -0800 Subject: [PATCH] Fix for embedded CSS ">" characters. --- src/index.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/index.js b/src/index.js index eeb36ee..17bc93d 100644 --- a/src/index.js +++ b/src/index.js @@ -14,7 +14,7 @@ function materialize_references_to_ipfs_content(node, element) { if (attribute_value && attribute_value.includes('./')) { let base_hash = window.location.pathname.match(/(^\/ipfs\/\w+)/)[1] let anchor = document.createElement('a') - let relative_url = attribute_value.match(/(.\/[^)]+)/)[1] + let relative_url = attribute_value.match(/(.\/[^)]*)/)[1] // Match "./foo/bar/baz" anchor.href = base_hash + relative_url.slice(1) console.log('loading IPFS sub-content for ' + anchor.pathname) @@ -58,7 +58,7 @@ function App() { // TODO: Should only do this if it's actually an HTML document. Need to gracefully skip this for other content types. let contents_document = new DOMParser().parseFromString(contents_buffer.toString(), 'text/html') - let elements = contents_document.querySelectorAll('link,meta,script,div') + let elements = contents_document.querySelectorAll('div,link,meta,script') let promises = [] for (let element of elements) { @@ -67,9 +67,7 @@ function App() { Promise.all(promises).then(function () { iframe.src = URL.createObjectURL( - new Blob([ - new XMLSerializer().serializeToString(contents_document) - ]) + new Blob([contents_document.documentElement.innerHTML]) ) document.body.appendChild(iframe)