Add optional baseURL override to Configuration#119
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 07d91bacd6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (opts.baseURL) { | ||
| try { | ||
| new URL(opts.baseURL); |
There was a problem hiding this comment.
If a caller passes baseURL: '' (e.g., from an unset env var), the opts.baseURL check is falsy so validation is skipped, but the constructor still uses the empty string because ?? does not fall back on ''. This results in Configuration.baseURL being empty, and later new URL(${request.baseURL}${request.url}) in src/resource.ts throws for relative-only URLs, breaking all requests at runtime. Consider treating empty/whitespace strings as invalid or falling back to the env default.
Useful? React with 👍 / 👎.
Motivation
Description
baseURL?: stringfield to theIConfigurationOptsinterface.Configurationconstructor to useopts.baseURL ?? \\https://${opts.env}.methodfi.com\`` and normalize the value by stripping trailing slashes withbaseURL.replace(/\/+$/, '').Configuration._validateConfigurationto throw a clear error for invalidbaseURLvalues.baseURLoption in theREADME.mdusage example showing how to point the SDK athttp://localhost:4010for local mocks.Testing
Codex Task