Skip to content

Commit

Permalink
fix(window.ipfs): stop injecting window.Buffer
Browse files Browse the repository at this point in the history
Closes #637
  • Loading branch information
lidel committed Jul 10, 2019
1 parent 126380c commit 4ca9a0c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 0 additions & 4 deletions add-on/src/contentScripts/ipfs-proxy/page.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict'

const _Buffer = Buffer
const { assign, freeze } = Object

// TODO: (wip) this should not be injected by default into every page,
Expand Down Expand Up @@ -46,7 +45,4 @@ function createWindowIpfs () {
return freeze(proxyClient)
}

// TODO: we should remove Buffer and add support for Uint8Array/ArrayBuffer natively
// See: https://github.com/ipfs/interface-ipfs-core/issues/404
window.Buffer = window.Buffer || _Buffer
window.ipfs = window.ipfs || createWindowIpfs()
7 changes: 7 additions & 0 deletions docs/examples/window.ipfs-fallback.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"/>
</head>
<body>
<div id="output"></div>
<script>
(() => {
Expand Down Expand Up @@ -39,3 +44,5 @@
.catch(log)
})()
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion docs/window.ipfs.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ if (window.ipfs && window.ipfs.enable) {
}
```

Note that IPFS Companion also adds `window.Buffer` if it doesn't already exist.
Note that IPFS Companion does not add `Buffer` to the global scope, you need to [get it on your own](https://github.com/feross/buffer).

See also: [How do I fallback if `window.ipfs` is not available?](#how-do-i-fallback-if-windowipfs-is-not-available)

Expand Down

0 comments on commit 4ca9a0c

Please sign in to comment.