fix(core): update

This commit is contained in:
Philipp Kunz 2022-02-15 18:57:42 +01:00
parent 92059a50de
commit d182832e47
8 changed files with 19 additions and 32 deletions

View File

@ -12,6 +12,9 @@ stages:
- release
- metadata
before_script:
- npm install -g @shipzone/npmci
# ====================
# security stage
# ====================
@ -36,6 +39,7 @@ auditProductionDependencies:
- npmci command npm audit --audit-level=high --only=prod --production
tags:
- docker
allow_failure: true
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci

24
.vscode/launch.json vendored
View File

@ -2,28 +2,10 @@
"version": "0.2.0",
"configurations": [
{
"name": "current file",
"type": "node",
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"args": [
"${relativeFile}"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "test.ts",
"type": "node",
"request": "launch",
"args": [
"test/test.ts"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
"type": "node-terminal"
}
]
}

View File

@ -12,7 +12,7 @@
"githost": "gitlab.com",
"gitscope": "pushrocks",
"gitrepo": "smartrequest",
"shortDescription": "dropin replacement for request",
"description": "dropin replacement for request",
"npmPackagename": "@pushrocks/smartrequest",
"license": "MIT"
}

View File

@ -52,4 +52,4 @@
"browserslist": [
"last 1 chrome versions"
]
}
}

View File

@ -3,7 +3,7 @@ import { tap, expect, expectAsync } from '@pushrocks/tapbundle';
import * as smartrequest from '../ts/index';
tap.test('should request a html document over https', async () => {
await expectAsync(smartrequest.getJson('https://encrypted.google.com/')).toHaveProperty('body')
await expectAsync(smartrequest.getJson('https://encrypted.google.com/')).toHaveProperty('body');
});
tap.test('should request a JSON document over https', async () => {

View File

@ -70,27 +70,28 @@ export const postFormData = async (
export const postFormDataUrlEncoded = async (
urlArg: string,
optionsArg: interfaces.ISmartRequestOptions = {},
payloadArg: {key: string, content: string}[]
payloadArg: { key: string; content: string }[]
) => {
const requestOptions = {
...optionsArg,
method: 'POST',
headers: {
...optionsArg.headers,
'content-type': 'application/x-www-form-urlencoded'
}
'content-type': 'application/x-www-form-urlencoded',
},
};
let resultString = '';
let resultString = '';
for (const keyContentPair of payloadArg) {
if (resultString) {
resultString += '&';
}
resultString += `${encodeURIComponent(keyContentPair.key)}=${encodeURIComponent(keyContentPair.content)}`;
resultString += `${encodeURIComponent(keyContentPair.key)}=${encodeURIComponent(
keyContentPair.content
)}`;
}
// lets fire the actual request for sending the formdata
const response = await request(urlArg + resultString, requestOptions);
return response;

View File

@ -5,5 +5,5 @@ export interface ISmartRequestOptions extends https.RequestOptions {
keepAlive?: boolean;
requestBody?: any;
autoJsonParse?: boolean;
queryParams?: {[key: string]: string}
queryParams?: { [key: string]: string };
}

View File

@ -104,7 +104,7 @@ export let request = async (
// parse url
const parsedUrl = plugins.smarturl.Smarturl.createFromUrl(urlArg, {
searchParams: optionsArg.queryParams || {}
searchParams: optionsArg.queryParams || {},
});
optionsArg.hostname = parsedUrl.hostname;
if (parsedUrl.port) {