Skip to content

Commit

Permalink
remove startsWith usage (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
bwoskow-ld authored Jul 10, 2020
1 parent ca937d3 commit fc3a857
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Requestor.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ export default function Requestor(platform, options, environment) {
const p = req.promise.then(
result => {
if (result.status === 200) {
if (result.header('content-type') && result.header('content-type').startsWith(jsonContentType)) {
// We're using substring here because using startsWith would require a polyfill in IE.
if (
result.header('content-type') &&
result.header('content-type').substring(0, jsonContentType.length) === jsonContentType
) {
return JSON.parse(result.body);
} else {
const message = messages.invalidContentType(result.header('content-type') || '');
Expand Down

0 comments on commit fc3a857

Please sign in to comment.