Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Fixing TypeError: Invalid calling object in Edge #70

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/client-oauth2.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ var Querystring = require('querystring')
var Url = require('url')
var defaultRequest = require('./request')

var btoa = typeof Buffer === 'function' ? btoaBuffer : window.btoa
// For some reason in some cases invoking window.btoa without binding causes TypeError 'Invalid calling object' in IE and Edge
// See for example https://github.com/tus/tus-js-client/issues/77
// I could not reproduce it in tests, but it did fail in a production project
// Binding fixes it
var btoa = typeof Buffer === 'function' ? btoaBuffer : window.btoa.bind(window)

/**
* Export `ClientOAuth2` class.
Expand Down