Comparing version 1.1.13 to 1.1.14
@@ -7,6 +7,14 @@ declare const showModal: () => void; | ||
declare const getRequestHeaders: (endpointId: string) => { | ||
[key: string]: string; | ||
[key: string]: { | ||
value: string; | ||
description: string; | ||
}; | ||
}; | ||
declare const getSelectedBaseUrl: () => string; | ||
declare const getQueryParameters: (endpointId: string) => string; | ||
declare function getQueryParameters(endpointId: string): { | ||
[key: string]: { | ||
value: string; | ||
description: string; | ||
}; | ||
}; | ||
declare const getAddressWithParameters: (endpointId: string, path: string) => string; | ||
@@ -13,0 +21,0 @@ declare function extractVariablesFromUrl(urlTemplate: string): string[]; |
@@ -22,7 +22,12 @@ "use strict"; | ||
const params = getQueryParameters(endpointId); | ||
let fullUrl = `${getAddressWithParameters(endpointId, path)}${params ? `?${params}` : ''}`; | ||
const urlParams = Object.keys(params).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(params[key].value)}`).join('&'); | ||
let fullUrl = `${getAddressWithParameters(endpointId, path)}${urlParams ? `?${urlParams}` : ''}`; | ||
if (!isValidHttpUrl(path)) { | ||
fullUrl = `${baseUrl}` + fullUrl; | ||
} | ||
const headers = getRequestHeaders(endpointId); | ||
const headerList = getRequestHeaders(endpointId); | ||
let headers = {}; | ||
Object.keys(headerList).forEach(key => { | ||
headers[key] = headerList[key].value; | ||
}); | ||
const body = getRequestBody(method, endpointId); | ||
@@ -57,3 +62,4 @@ responseSection?.classList.add("displayNon"); | ||
const params = getQueryParameters(endpointId); | ||
let fullUrl = `${path}${params ? `?${params}` : ''}`; | ||
const urlParams = Object.keys(params).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(params[key].value)}`).join('&'); | ||
let fullUrl = `${path}${urlParams ? `?${urlParams}` : ''}`; | ||
if (!isValidHttpUrl(path)) { | ||
@@ -76,2 +82,5 @@ fullUrl = `${baseUrl}` + fullUrl; | ||
} | ||
if (params) { | ||
destinationPath += `¶ms=${JSON.stringify(params)}`; | ||
} | ||
if (body && requestBody?.type) { | ||
@@ -89,9 +98,14 @@ destinationPath += `&body=${body}&bodyType=${requestBody?.type}`; | ||
const key = input.getAttribute('header-data-key') || ''; | ||
headers[key] = input.value; | ||
const description = document.getElementById(`${key}_description`).innerHTML; | ||
headers[key] = { value: input.value, description }; | ||
}); | ||
if (requestHeaders) { | ||
Array.from(requestHeaders.getElementsByTagName("tr")).forEach(tr => { | ||
const key = tr.getElementsByTagName('td')[0].firstElementChild.value; | ||
const value = tr.getElementsByTagName('td')[1].firstElementChild.value; | ||
headers[key] = value; | ||
const rows = requestHeaders.querySelectorAll("tr.data-row"); | ||
rows.forEach(row => { | ||
const key = row.querySelector('input[name="key"]').value; | ||
const value = row.querySelector('input[name="value"]').value; | ||
const description = row.querySelector('input[name="description"]').value; | ||
if (key && value) { | ||
headers[key] = { value, description }; | ||
} | ||
}); | ||
@@ -105,13 +119,16 @@ } | ||
}; | ||
// Get query parameters | ||
const getQueryParameters = (endpointId) => { | ||
function getQueryParameters(endpointId) { | ||
const params = {}; | ||
const paramBody = document.getElementById(`${endpointId}_query_params_body`); | ||
return Array.from(paramBody.getElementsByTagName("tr")) | ||
.map(tr => { | ||
const key = tr.getElementsByTagName('td')[0].firstElementChild.value; | ||
const value = tr.getElementsByTagName('td')[1].firstElementChild.value; | ||
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`; | ||
}) | ||
.join('&'); | ||
}; | ||
const rows = paramBody.querySelectorAll("tr.data-row"); | ||
rows.forEach(row => { | ||
const key = row.querySelector('input[name="key"]').value; | ||
const value = row.querySelector('input[name="value"]').value; | ||
const description = row.querySelector('input[name="description"]').value; | ||
if (key && value) { | ||
params[key] = { value, description }; | ||
} | ||
}); | ||
return params; | ||
} | ||
// Get query parameters | ||
@@ -118,0 +135,0 @@ const getAddressWithParameters = (endpointId, path) => { |
@@ -13,2 +13,3 @@ declare const bodyTypeSelectElement: HTMLSelectElement; | ||
declare function loadMethod(method?: string): void; | ||
declare function loadParams(params?: string): void; | ||
declare function loadHeaders(headers?: string): void; | ||
@@ -15,0 +16,0 @@ declare function loadBodyType(bodyType?: string): void; |
@@ -22,2 +22,4 @@ "use strict"; | ||
loadHeaders(params.headers); | ||
loadParams(params.params); | ||
updateURL(); | ||
loadBodyType(params.bodyType); | ||
@@ -29,3 +31,2 @@ loadBody(params.bodyType, params.body); | ||
urlInput.value = decodeURIComponent(url); | ||
syncTableWithURL(); | ||
} | ||
@@ -38,2 +39,14 @@ } | ||
} | ||
function loadParams(params) { | ||
if (params) { | ||
const paramsObj = JSON.parse(params); | ||
const headersTableBody = document.querySelector('#parametersTable tbody'); | ||
if (headersTableBody && Object.keys(paramsObj).length !== 0) { | ||
headersTableBody.innerHTML = ""; | ||
} | ||
Object.keys(paramsObj).forEach(key => { | ||
addRow("parametersTable", key, paramsObj[key].value, paramsObj[key].description); | ||
}); | ||
} | ||
} | ||
function loadHeaders(headers) { | ||
@@ -47,3 +60,3 @@ if (headers) { | ||
Object.keys(headerObj).forEach(key => { | ||
addRow("headersTable", key, headerObj[key]); | ||
addRow("headersTable", key, headerObj[key].value, headerObj[key].description); | ||
}); | ||
@@ -50,0 +63,0 @@ } |
@@ -256,3 +256,3 @@ // @ts-ignore | ||
<input id="${key}_value" header-data-key="${key}" type="text" class="input-field" value="${value}"> | ||
<p class="header-description">${description}</p> | ||
<p id="${key}_description" class="header-description">${description}</p> | ||
</div> | ||
@@ -301,3 +301,3 @@ </div> | ||
<td class="data-cell"><input class="param-cell-input border-background-non" placeholder="value" name="value" value="${header.value}"></input></td> | ||
<td class="data-cell"><input class="param-cell-input" disabled placeholder="description" value="${header.description}"></input></td> | ||
<td class="data-cell"><input class="param-cell-input" disabled placeholder="description" name="description" value="${header.description}"></input></td> | ||
</tr> | ||
@@ -304,0 +304,0 @@ `; |
{ | ||
"name": "outport", | ||
"version": "1.1.13", | ||
"version": "1.1.14", | ||
"main": "./lib/index.js", | ||
@@ -5,0 +5,0 @@ "types": "./lib/index.d.ts", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
126568
2428