Merge branch 'refactor'

This commit is contained in:
Liyas Thomas
2020-09-24 21:39:14 +05:30
15 changed files with 27 additions and 51 deletions

View File

@@ -8,7 +8,7 @@ const PW_BUILD_DATA_DIR = "./.hoppscotch"
// const IS_DEV_MODE = process.argv.includes("--dev")
try {
;(async () => {
(async () => {
// Create the build data directory if it does not exist.
if (!fs.existsSync(PW_BUILD_DATA_DIR)) {
fs.mkdirSync(PW_BUILD_DATA_DIR)

View File

@@ -320,10 +320,10 @@ export default {
return items
},
hasFolder(item) {
return item.hasOwnProperty("item")
return Object.prototype.hasOwnProperty.call(item, "item")
},
isSubFolder(item) {
return item.hasOwnProperty("_postman_isSubFolder") && item._postman_isSubFolder
return Object.prototype.hasOwnProperty.call(item, "_postman_isSubFolder") && item._postman_isSubFolder
},
flattenPostmanItem(subFolder, subFolderGlue = " -- ") {
delete subFolder._postman_isSubFolder

View File

@@ -36,6 +36,7 @@ export default {
theme: {
type: String,
required: false,
default: null,
},
onRunGQLQuery: {
type: Function,

View File

@@ -312,7 +312,6 @@ import {
hasFirefoxExtensionInstalled,
} from "~/helpers/strategies/ExtensionStrategy"
import { getPlatformSpecialKey } from "~/helpers/platformutils"
import firebase from "firebase/app"
import { fb } from "~/helpers/fb"
import closeIcon from "~/static/icons/close-24px.svg?inline"

View File

@@ -33,6 +33,7 @@ export default {
theme: {
type: String,
required: false,
default: null,
},
lang: {
type: String,

View File

@@ -21,7 +21,6 @@
<script>
import ace from "ace-builds"
import "ace-builds/webpack-resolver"
import jsonParse from "~/helpers/jsonParse"
import debounce from "~/helpers/utils/debounce"
import * as esprima from "esprima"
@@ -35,6 +34,7 @@ export default {
theme: {
type: String,
required: false,
default: null,
},
options: {
type: Object,

View File

@@ -7,10 +7,11 @@
<script>
export default {
props: {
label: { type: String },
icon: { type: String },
label: { type: String, default: "" },
icon: { type: String, default: "" },
id: { required: true },
selected: {
type: Boolean,
default: false,
},
},

View File

@@ -18,7 +18,7 @@
<script>
export default {
props: {
value: { type: String },
value: { type: String, default: "" },
},
data() {
return {

View File

@@ -1,9 +0,0 @@
{
"baseUrl": "http://localhost:3000",
"integrationFolder": "tests/e2e/integration",
"screenshotsFolder": "tests/e2e/screenshots",
"fixturesFolder": "tests/e2e/fixtures",
"supportFile": "tests/e2e/support",
"pluginsFile": false,
"video": false
}

View File

@@ -102,7 +102,7 @@ class Expectation {
: this._fail(this._fmtNot(`Expected ${this.expectValue} (not)to be ${value}`))
}
toHaveProperty(value) {
return this._satisfies(this.expectValue.hasOwnProperty(value), true)
return this._satisfies(Object.prototype.hasOwnProperty.call(this.expectValue, value), true)
? this._pass()
: this._fail(
this._fmtNot(`Expected object ${this.expectValue} to (not)have property ${value}`)

View File

@@ -1,9 +1,3 @@
[build]
command = "npm run generate"
functions = "netlify/"
[[redirects]]
from = "https://postwoman.io"
to = "https://hoppscotch.io"
status = 301
force = true

View File

@@ -329,7 +329,6 @@
</style>
<script>
import axios from "axios"
import * as gql from "graphql"
import { commonHeaders } from "~/helpers/headers"
import { getPlatformSpecialKey } from "~/helpers/platformutils"

View File

@@ -171,7 +171,6 @@
<i class="material-icons">send</i>
</span>
</button>
<button v-else @click="cancelRequest" id="send" ref="sendButton">
{{ $t("cancel") }}
<span>
@@ -1297,20 +1296,6 @@ const statusCategories = [
className: "missing-data-response",
},
]
const parseHeaders = (xhr) => {
const headers = xhr
.getAllResponseHeaders()
.trim()
.split(/[\r\n]+/)
const headerMap = {}
headers.forEach((line) => {
const parts = line.split(": ")
const header = parts.shift().toLowerCase()
const value = parts.join(": ")
headerMap[header] = value
})
return headerMap
}
export const findStatusGroup = (responseStatus) =>
statusCategories.find(({ statusCodeRegex }) => statusCodeRegex.test(responseStatus))
@@ -2071,14 +2056,14 @@ export default {
icon: "done",
})
;(() => {
const status = (this.response.status = payload.status)
const headers = (this.response.headers = payload.headers)
this.response.status = payload.status
this.response.headers = payload.headers
// We don't need to bother parsing JSON, axios already handles it for us!
const body = (this.response.body = payload.data)
this.response.body = payload.data
// Addition of an entry to the history component.
const entry = {
label: this.requestName,
status,
status: this.response.status,
date: new Date().toLocaleDateString(),
time: new Date().toLocaleTimeString(),
method: this.method,
@@ -2222,7 +2207,7 @@ export default {
getQueryStringFromPath() {
let queryString
const pathParsed = url.parse(this.uri)
return (queryString = pathParsed.query ? pathParsed.query : "")
return pathParsed.query ? pathParsed.query : ""
},
queryStringToArray(queryString) {
const queryParsed = querystring.parse(queryString)
@@ -2619,7 +2604,7 @@ export default {
},
async oauthRedirectReq() {
const tokenInfo = await oauthRedirect()
if (tokenInfo.hasOwnProperty("access_token")) {
if (Object.prototype.hasOwnProperty.call(tokenInfo, "access_token")) {
this.bearerToken = tokenInfo.access_token
this.addOAuthToken({
name: this.accessTokenName,
@@ -2735,7 +2720,7 @@ export default {
if ((e.key === "u" || e.key === "U") && e.altKey) {
this.method = "PUT"
}
if ((e.key === "x" || e.key === "x") && e.altKey) {
if ((e.key === "x" || e.key === "X") && e.altKey) {
this.method = "DELETE"
}
if (e.key == "ArrowUp" && e.altKey && this.currentMethodIndex > 0) {

View File

@@ -217,7 +217,6 @@
</template>
<script>
import firebase from "firebase/app"
import { fb } from "~/helpers/fb"
import { hasExtensionInstalled } from "../helpers/strategies/ExtensionStrategy"

View File

@@ -301,9 +301,12 @@ export const mutations = {
const { request } = payload
// Remove the old request from collection
if (request.hasOwnProperty("oldCollection") && request.oldCollection > -1) {
if (
Object.prototype.hasOwnProperty.call(request, "oldCollection") &&
request.oldCollection > -1
) {
const folder =
request.hasOwnProperty("oldFolder") && request.oldFolder >= -1
Object.prototype.hasOwnProperty.call(request, "oldFolder") && request.oldFolder >= -1
? request.oldFolder
: request.folder
if (folder > -1) {
@@ -311,7 +314,10 @@ export const mutations = {
} else {
collections[request.oldCollection].requests.splice(request.requestIndex, 1)
}
} else if (request.hasOwnProperty("oldFolder") && request.oldFolder !== -1) {
} else if (
Object.prototype.hasOwnProperty.call(request, "oldFolder") &&
request.oldFolder !== -1
) {
collections[request.collection].folders[folder].requests.splice(request.requestIndex, 1)
}