-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bugfix(#2431) Refactor URL construction in Postman collection processing #2445
Conversation
const constructUrl = (url) => { | ||
let urlStr = ''; | ||
if (typeof url === 'string') { | ||
urlStr = url; | ||
} else if (url.raw) { | ||
urlStr = url.raw; | ||
} else { | ||
const { protocol, host, path, port, query } = url; | ||
const hostStr = Array.isArray(host) ? host.join('.') : host; | ||
const pathStr = Array.isArray(path) ? path.join('/') : path; | ||
const portStr = port ? `:${port}` : ''; | ||
const queryStr = query && query.length > 0 ? `?${query.map((q) => `${q.key}=${q.value}`).join('&')}` : ''; | ||
urlStr = `${protocol}://${hostStr}${portStr}/${pathStr}${queryStr}`; | ||
} | ||
return urlStr; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check this case please, this is losing hash section of url:
"item": [
{
"name": "Request",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "https://localhost/param1/param2?param3¶m4=b¶m5=(size=small;color=red)#this-is-framgment",
"protocol": "https",
"host": [
"localhost"
],
"path": [
"param1",
"param2"
],
"query": [
{
"key": "param3",
"value": null
},
{
"key": "param4",
"value": "b"
},
{
"key": "param5",
"value": "(size=small;color=red)"
}
],
"hash": "this-is-framgment"
}
},
"response": []
}
]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the review. I believe we should not include the hash values in the URL. As per Wikipedia,
"The fragment identifier functions differently to the rest of the URI: its processing is exclusively client-sided with no participation from the web server"
— Wikipedia
…en there is a param with its key as undefined we discard it.
Description
Fixes #2431
Fixes #3113
Contribution Checklist:
Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.
Publishing to New Package Managers
Please see here for more information.