twitch-oauth
Advanced tools
Comparing version 0.1.1 to 0.1.2
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.jsonToURLEncoded = void 0; | ||
const querystring_1 = __importDefault(require("querystring")); | ||
function isomorphicEscape(value) { | ||
if (typeof window === 'undefined') { | ||
return querystring_1.default.escape(value); | ||
} | ||
else { | ||
return encodeURIComponent(value); | ||
} | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
@@ -12,3 +24,3 @@ function jsonToURLEncoded(object) { | ||
} | ||
queries.push(key + '=' + encodeURIComponent(value)); | ||
queries.push(key + '=' + isomorphicEscape(value)); | ||
} | ||
@@ -15,0 +27,0 @@ return queries.join('&'); |
@@ -5,3 +5,3 @@ { | ||
"description": "Authenticate users with Twitch.", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"license": "MIT", | ||
@@ -8,0 +8,0 @@ "main": "lib/index.js", |
@@ -0,4 +1,14 @@ | ||
import qs from 'querystring'; | ||
function isomorphicEscape(value: string) { | ||
if (typeof window === 'undefined') { | ||
return qs.escape(value); | ||
} else { | ||
return encodeURIComponent(value); | ||
} | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export function jsonToURLEncoded(object: Record<string, any>) { | ||
const queries = []; | ||
const queries: string[] = []; | ||
for (const key in object) { | ||
@@ -10,5 +20,5 @@ let value = object[key]; | ||
queries.push(key + '=' + encodeURIComponent(value)); | ||
queries.push(key + '=' + isomorphicEscape(value)); | ||
} | ||
return queries.join('&'); | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
16944
237