Skip to content
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

feat: strip protocol from host if provided during upload [EXT-00] #2151

Merged
merged 3 commits into from
Oct 1, 2024

Conversation

jjolton-contentful
Copy link
Contributor

This PR addresses an issue where specifying a host that starts with http:// or https:// causes the upload process to break.

To fix this, an inquirer filter function has been added to the host prompt in buildAppUploadSettings. This function strips out any leading http:// or https:// from the user's input, ensuring that only the base URL is used.

@jjolton-contentful jjolton-contentful requested a review from a team as a code owner September 27, 2024 19:55
@jjolton-contentful jjolton-contentful marked this pull request as draft September 27, 2024 19:55
@jjolton-contentful jjolton-contentful force-pushed the feat/strip-host-protocol-during-upload branch 3 times, most recently from 43b52af to 24f5920 Compare September 27, 2024 21:39
@jjolton-contentful jjolton-contentful force-pushed the feat/strip-host-protocol-during-upload branch from 24f5920 to 62a4d15 Compare September 27, 2024 21:43
@jjolton-contentful jjolton-contentful marked this pull request as ready for review September 27, 2024 21:47
@@ -55,3 +56,7 @@ export async function buildAppUploadSettings(options: UploadOptions): Promise<Up
...appInfo,
};
}

export function hostProtocolFilter (input: string) {
return input.replace(/^https?:\/\//, '');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this catch http:// as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does indeed but I probably should have added a test case for http too huh

Welcome to Node.js v20.17.0.
Type ".help" for more information.
> "http://api.contentful.com".replace(/^https?:\/\//, '')
'api.contentful.com'
> "https://api.contentful.com".replace(/^https?:\/\//, '')
'api.contentful.com'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added in 483466d

@jjolton-contentful jjolton-contentful merged commit 6bbe36d into main Oct 1, 2024
14 checks passed
@jjolton-contentful jjolton-contentful deleted the feat/strip-host-protocol-during-upload branch October 1, 2024 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants