refactor: lint
This commit is contained in:
@@ -5,7 +5,9 @@ describe("decodeB64StringToArrayBuffer", () => {
|
||||
test("decodes content correctly", () => {
|
||||
const decoder = new TextDecoder("utf-8")
|
||||
expect(
|
||||
decoder.decode(decodeB64StringToArrayBuffer("aG9wcHNjb3RjaCBpcyBhd2Vzb21lIQ=="))
|
||||
decoder.decode(
|
||||
decodeB64StringToArrayBuffer("aG9wcHNjb3RjaCBpcyBhd2Vzb21lIQ==")
|
||||
)
|
||||
).toMatch("hoppscotch is awesome!")
|
||||
})
|
||||
|
||||
|
||||
@@ -10,7 +10,9 @@ describe("isJSONContentType", () => {
|
||||
|
||||
test("returns true for JSON types with charset specified", () => {
|
||||
expect(isJSONContentType("application/json; charset=utf-8")).toBe(true)
|
||||
expect(isJSONContentType("application/vnd.api+json; charset=utf-8")).toBe(true)
|
||||
expect(isJSONContentType("application/vnd.api+json; charset=utf-8")).toBe(
|
||||
true
|
||||
)
|
||||
expect(isJSONContentType("application/hal+json; charset=utf-8")).toBe(true)
|
||||
expect(isJSONContentType("application/ld+json; charset=utf-8")).toBe(true)
|
||||
})
|
||||
@@ -25,7 +27,9 @@ describe("isJSONContentType", () => {
|
||||
test("returns false for non-JSON content types with charset", () => {
|
||||
expect(isJSONContentType("application/xml; charset=utf-8")).toBe(false)
|
||||
expect(isJSONContentType("text/html; charset=utf-8")).toBe(false)
|
||||
expect(isJSONContentType("application/x-www-form-urlencoded; charset=utf-8")).toBe(false)
|
||||
expect(
|
||||
isJSONContentType("application/x-www-form-urlencoded; charset=utf-8")
|
||||
).toBe(false)
|
||||
expect(isJSONContentType("foo/jsoninword; charset=utf-8")).toBe(false)
|
||||
})
|
||||
|
||||
|
||||
@@ -3,16 +3,17 @@ export const decodeB64StringToArrayBuffer = (input) => {
|
||||
const ab = new ArrayBuffer(bytes)
|
||||
const uarray = new Uint8Array(ab)
|
||||
|
||||
const keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
|
||||
const keyStr =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
|
||||
|
||||
let chr1, chr2, chr3
|
||||
let enc1, enc2, enc3, enc4
|
||||
let j = 0
|
||||
|
||||
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "")
|
||||
input = input.replace(/[^A-Za-z0-9+/=]/g, "")
|
||||
|
||||
for (let i = 0; i < bytes; i += 3) {
|
||||
//get the 3 octets in 4 ASCII chars
|
||||
// get the 3 octets in 4 ASCII chars
|
||||
enc1 = keyStr.indexOf(input.charAt(j++))
|
||||
enc2 = keyStr.indexOf(input.charAt(j++))
|
||||
enc3 = keyStr.indexOf(input.charAt(j++))
|
||||
@@ -23,8 +24,8 @@ export const decodeB64StringToArrayBuffer = (input) => {
|
||||
chr3 = ((enc3 & 3) << 6) | enc4
|
||||
|
||||
uarray[i] = chr1
|
||||
if (enc3 != 64) uarray[i + 1] = chr2
|
||||
if (enc4 != 64) uarray[i + 2] = chr3
|
||||
if (enc3 !== 64) uarray[i + 1] = chr2
|
||||
if (enc4 !== 64) uarray[i + 2] = chr3
|
||||
}
|
||||
|
||||
return ab
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
export function parseUrlAndPath(value) {
|
||||
let result = {}
|
||||
const result = {}
|
||||
try {
|
||||
let url = new URL(value)
|
||||
const url = new URL(value)
|
||||
result.url = url.origin
|
||||
result.path = url.pathname
|
||||
} catch (error) {
|
||||
let uriRegex = value.match(/^((http[s]?:\/\/)?(<<[^\/]+>>)?[^\/]*|)(\/?.*)$/)
|
||||
const uriRegex = value.match(
|
||||
/^((http[s]?:\/\/)?(<<[^/]+>>)?[^/]*|)(\/?.*)$/
|
||||
)
|
||||
result.url = uriRegex[1]
|
||||
result.path = uriRegex[4]
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const [wsRegexIP, wsRegexHostname] = generateREForProtocol("^(wss?:\\/\\/)?")
|
||||
const [sseRegexIP, sseRegexHostname] = generateREForProtocol("^(https?:\\/\\/)?")
|
||||
const [sseRegexIP, sseRegexHostname] =
|
||||
generateREForProtocol("^(https?:\\/\\/)?")
|
||||
const [socketioRegexIP, socketioRegexHostname] = generateREForProtocol(
|
||||
"^((wss?:\\/\\/)|(https?:\\/\\/))?"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user