Fix for embedded CSS ">" characters.
This commit is contained in:
parent
c75b3dc50c
commit
9b998a6318
|
@ -14,7 +14,7 @@ function materialize_references_to_ipfs_content(node, element) {
|
||||||
if (attribute_value && attribute_value.includes('./')) {
|
if (attribute_value && attribute_value.includes('./')) {
|
||||||
let base_hash = window.location.pathname.match(/(^\/ipfs\/\w+)/)[1]
|
let base_hash = window.location.pathname.match(/(^\/ipfs\/\w+)/)[1]
|
||||||
let anchor = document.createElement('a')
|
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)
|
anchor.href = base_hash + relative_url.slice(1)
|
||||||
console.log('loading IPFS sub-content for ' + anchor.pathname)
|
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.
|
// 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 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 = []
|
let promises = []
|
||||||
|
|
||||||
for (let element of elements) {
|
for (let element of elements) {
|
||||||
|
@ -67,9 +67,7 @@ function App() {
|
||||||
|
|
||||||
Promise.all(promises).then(function () {
|
Promise.all(promises).then(function () {
|
||||||
iframe.src = URL.createObjectURL(
|
iframe.src = URL.createObjectURL(
|
||||||
new Blob([
|
new Blob([contents_document.documentElement.innerHTML])
|
||||||
new XMLSerializer().serializeToString(contents_document)
|
|
||||||
])
|
|
||||||
)
|
)
|
||||||
|
|
||||||
document.body.appendChild(iframe)
|
document.body.appendChild(iframe)
|
||||||
|
|
Reference in New Issue