Skip to content

Commit 374d4d6

Browse files
authored
Merge pull request #25 from postmanlabs/release/v1.0.3
Release version v1.0.3
2 parents c91b0a2 + 6b6ae24 commit 374d4d6

File tree

11 files changed

+4545
-154
lines changed

11 files changed

+4545
-154
lines changed

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"parserOptions": {
3-
"ecmaVersion": 2015
3+
"ecmaVersion": 2020
44
},
55
"plugins": [
66
"security",

.github/workflows/Integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ jobs:
1010
- uses: actions/checkout@v2
1111
- uses: actions/setup-node@v1
1212
with:
13-
node-version: '14.x'
13+
node-version: '16.x'
1414
- run: npm ci
1515
- run: npm run test
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Draft new release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: The version you want to release. Must be a valid semver version.
8+
required: true
9+
type: string
10+
11+
jobs:
12+
draft-new-release:
13+
if: startsWith(github.event.inputs.version, 'v')
14+
name: Draft a new release
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: write
18+
pull-requests: write
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v3
23+
24+
- name: Create release branch
25+
run: git checkout -b release/${{ github.event.inputs.version }}
26+
27+
- name: Update changelog
28+
uses: thomaseizinger/[email protected]
29+
with:
30+
version: ${{ github.event.inputs.version }}
31+
32+
- name: Initialize mandatory git config
33+
run: |
34+
git config user.name "GitHub Actions"
35+
git config user.email [email protected]
36+
37+
- name: Bump version
38+
run: npm version ${{ github.event.inputs.version }} --git-tag-version false
39+
40+
- name: Commit changelog and manifest files
41+
id: make-commit
42+
run: |
43+
git add CHANGELOG.md package.json package-lock.json
44+
git commit --message "Prepare release ${{ github.event.inputs.version }}"
45+
echo "::set-output name=commit::$(git rev-parse HEAD)"
46+
47+
- name: Push new branch
48+
run: git push origin release/${{ github.event.inputs.version }}
49+
50+
- name: Create pull request for main
51+
uses: thomaseizinger/[email protected]
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
with:
55+
head: release/${{ github.event.inputs.version }}
56+
base: main
57+
title: "Release version ${{ github.event.inputs.version }}"
58+
reviewers: ${{ github.actor }}
59+
body: |
60+
Hi @${{ github.actor }}!
61+
62+
This PR was created in response to a manual trigger of the release workflow here: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}.
63+
I've updated the changelog and bumped the versions in the manifest files in this commit: ${{ steps.make-commit.outputs.commit }}.
64+
65+
- name: Create pull request for development
66+
uses: thomaseizinger/[email protected]
67+
env:
68+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69+
with:
70+
head: release/${{ github.event.inputs.version }}
71+
base: development
72+
title: "Release version ${{ github.event.inputs.version }}"
73+
reviewers: ${{ github.actor }}
74+
body: |
75+
Hi @${{ github.actor }}!
76+
77+
This PR was created in response to a manual trigger of the release workflow here: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}.
78+
I've updated the changelog and bumped the versions in the manifest files in this commit: ${{ steps.make-commit.outputs.commit }}.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: "Publish new release"
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
types:
8+
- closed
9+
10+
jobs:
11+
release:
12+
name: Publish new release
13+
runs-on: ubuntu-latest
14+
# only merged pull requests that begin with 'release/' or 'hotfix/' must trigger this job
15+
if: github.event.pull_request.merged == true &&
16+
(contains(github.event.pull_request.head.ref, 'release/') || contains(github.event.pull_request.head.ref, 'hotfix/'))
17+
permissions:
18+
contents: write
19+
20+
steps:
21+
- name: Extract version from branch name (for release branches)
22+
if: contains(github.event.pull_request.head.ref, 'release/')
23+
run: |
24+
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
25+
VERSION=${BRANCH_NAME#release/}
26+
27+
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
28+
29+
- name: Extract version from branch name (for hotfix branches)
30+
if: contains(github.event.pull_request.head.ref, 'hotfix/')
31+
run: |
32+
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
33+
VERSION=${BRANCH_NAME#hotfix/}
34+
35+
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
36+
37+
- name: Create Release
38+
uses: thomaseizinger/[email protected]
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
with:
42+
target_commitish: ${{ github.event.pull_request.merge_commit_sha }}
43+
tag_name: ${{ env.RELEASE_VERSION }}
44+
name: ${{ env.RELEASE_VERSION }}
45+
draft: false
46+
prerelease: false

CHANGELOG.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
1+
# HAR to Postman Changelog
2+
3+
## [Unreleased]
4+
5+
## [v1.0.3] - 2024-02-15
6+
7+
### Fixed
8+
9+
- Fixed few of frequent type errors.
10+
111
#### v1.0.2 (March 16, 2022)
2-
* Fix explicit usage of Space as an indendation type leading to `Space` word in the converted collection
3-
* Loosen HAR validations on statusText and redirectURL fields to support null value
4-
* Use the textual representation instead of throwing errors in case of invalid JSON in the body
12+
13+
- Fix explicit usage of Space as an indendation type leading to `Space` word in the converted collection
14+
- Loosen HAR validations on statusText and redirectURL fields to support null value
15+
- Use the textual representation instead of throwing errors in case of invalid JSON in the body
516

617
#### v1.0.1 (December 22, 2021)
7-
* Skip validations for optional fields in the HAR spec that are not required for conversion to a collection
18+
19+
- Skip validations for optional fields in the HAR spec that are not required for conversion to a collection
20+
821
#### v1.0.0 (December 8, 2021)
9-
* Base release
22+
23+
- Base release
24+
25+
[Unreleased]: https://github.com/postmanlabs/har-to-postman/compare/v1.0.3...HEAD
26+
27+
[v1.0.3]: https://github.com/postmanlabs/har-to-postman/compare/03ce42a1fd66ba053850cbfb3c75f3d3fab62c0f...v1.0.3

lib/HARToPostmanCollectionBodyMapper.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -157,18 +157,18 @@ function isMimeType(mimeType, expectedMimeType) {
157157
* @returns {array} the list of parameters in the url
158158
*/
159159
function getParamsFromEncoded(harRequest) {
160-
const urlParamsArray = harRequest.postData.params,
161-
urlParamsAsText = harRequest.postData.text;
160+
const urlParamsArray = harRequest?.postData?.params,
161+
urlParamsAsText = harRequest?.postData?.text;
162162
let params = [];
163-
if (urlParamsArray.length > 0) {
163+
if (urlParamsArray?.length > 0) {
164164
params = urlParamsArray.map((param) => {
165165
return {
166166
key: param.name,
167167
value: param.value
168168
};
169169
});
170170
}
171-
else if (urlParamsAsText) {
171+
else if (typeof urlParamsAsText === 'string') {
172172
params = urlParamsAsText.split('&')
173173
.map((keyValueAsText) => {
174174
let [key, value] = keyValueAsText.split('=');
@@ -190,11 +190,11 @@ function getParamsFromEncoded(harRequest) {
190190
* @returns {boolean} true if request privides from a har generated in safari
191191
*/
192192
function isSafariUrlEncoded(harRequest) {
193-
const hasNoParams = harRequest.postData.params !== undefined &&
194-
harRequest.postData.params.length === 0,
195-
hasNoMimeType = harRequest.postData.mimeType === '',
193+
const hasNoParams = harRequest?.postData?.params !== undefined &&
194+
harRequest.postData.params?.length === 0,
195+
hasNoMimeType = harRequest?.postData?.mimeType === '',
196196
paramsInTextPattern = new RegExp('\\w*=[\\w\\s]+', 'g'),
197-
contentText = harRequest.postData.text,
197+
contentText = harRequest?.postData?.text || '',
198198
paramsInTextByPattern = contentText.match(paramsInTextPattern),
199199
paramsInTextBySplit = contentText.split('&'),
200200
textContainsParams = paramsInTextByPattern &&
@@ -215,7 +215,7 @@ function isSafariUrlEncoded(harRequest) {
215215
function mapBody(harRequest, options) {
216216
let handledBody;
217217
if (harRequest.bodySize > 0) {
218-
const mimeType = harRequest.postData.mimeType;
218+
const mimeType = harRequest?.postData?.mimeType;
219219
if (isMimeType(mimeType, SUPPORTED_BODY_TYPES.applicationJson)) {
220220
handledBody = mapBodyFromJson(harRequest, options);
221221
}
@@ -251,8 +251,8 @@ function mapBody(harRequest, options) {
251251
*/
252252
function mapBodyResponse(harResponse, options) {
253253
let handledBody;
254-
if (harResponse.content.size > 0) {
255-
const mimeType = harResponse.content.mimeType;
254+
if (harResponse?.content?.size > 0) {
255+
const mimeType = harResponse?.content?.mimeType;
256256

257257
switch (mimeType) {
258258
case SUPPORTED_BODY_TYPES.applicationJson:

lib/utils/urlUtils.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ function decodeURL(url) {
4747
if (url === undefined) {
4848
return '';
4949
}
50-
return decodeURIComponent((String(url)).replace(/\+/g, '%20'));
50+
51+
try {
52+
return decodeURIComponent((String(url)).replace(/\+/g, '%20'));
53+
}
54+
catch (e) {
55+
return String(url);
56+
}
5157
}
5258

5359
module.exports = {

0 commit comments

Comments
 (0)