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: support relative paths when generating rest handlers #268

Merged
merged 1 commit into from
Mar 28, 2023

Conversation

timkolotov
Copy link
Contributor

@timkolotov timkolotov commented Mar 5, 2023

Removes usage of URL constructor in createUrlBuilder which is used for generating REST handlers.
Approach with strings concatenation allows us to use relative paths without specific hostnames, provide prefixes, and also use parameters in the baseUrl that will be handled by MSW.

I also added removing trailing slashes from the baseUrl, as previously it could be passed with and without it and won't affect the result, so I keep it like it was to avoid breaking changes.
Additionally updated tests for the function: removed the leading slash. Because buildUrl calls inside generateRestHandlers have no leading shashes so tests weren't exactly correct.

(ref: #267)

@timkolotov timkolotov force-pushed the feat/rest-handlers-relative-paths branch 2 times, most recently from 12469b7 to 0695b58 Compare March 5, 2023 10:40
Copy link
Member

@kettanaito kettanaito left a comment

Choose a reason for hiding this comment

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

Looks great! Thank you for fixing this, @timkolotov! 🎉

@timkolotov
Copy link
Contributor Author

@kettanaito Something seems to be very wrong with the CI. I don't know much about CI in GitHub, but perhaps actions/checkout must be updated?
I had such an error locally in another project, was related to OpenSSL and Node...

@kettanaito
Copy link
Member

Yeah, the issue seems to be not related to your changes. I will look into that.

@timkolotov
Copy link
Contributor Author

@kettanaito anything here?

@timkolotov
Copy link
Contributor Author

@kettanaito fixed it, I guess #270 (still can't request the review)

@kettanaito
Copy link
Member

Thanks for fixing that, @timkolotov. Could you please rebase this branch? The CI issue should be gone then.

@timkolotov timkolotov force-pushed the feat/rest-handlers-relative-paths branch from 0695b58 to 0179761 Compare March 28, 2023 14:00
@timkolotov
Copy link
Contributor Author

Seems all good now 😃

Copy link
Member

@kettanaito kettanaito left a comment

Choose a reason for hiding this comment

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

🚀

@kettanaito kettanaito merged commit 2670d00 into mswjs:main Mar 28, 2023
@kettanaito
Copy link
Member

Released: v0.12.0 🎉

This has been released in v0.12.0!

Make sure to always update to the latest version (npm i @mswjs/data@latest) to get the newest features and bug fixes.


Predictable release automation by @ossjs/release.

@timkolotov timkolotov deleted the feat/rest-handlers-relative-paths branch April 9, 2023 03:39
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.

None yet

2 participants