Closed jimmymcpeter closed 1 month ago
Hi, maybe I'm confused but I was trying to follow the OAS for paths
A relative path to an individual endpoint. The field name MUST begin with a forward slash (/). The path is appended (no relative URL resolution) to the expanded URL from the Server Object’s url field in order to construct the full URL
My bad, got things confused. There are two key points to solving this:
path
segment must start with a dot to denote relative path to the full server URL.new URL('/bar', 'https://example.com/foo')
// https://example.com/bar
new URL('./bar', 'https://example.com/foo/')
// https://example.com/foo/bar
I'm curious why not just append the path to the server URL like the spec says? It shouldn't be doing any URL relative resolution, which is what URL() does when you pass a base parameter to it
@jimmymcpeter, behavior-wise, there should be no difference. I just prefer using the baseURL
argument of URL
, but in this case it may redundant, I agree.
I wish URL handled double slashes //
but those are legitimate URL tokens.
This has been released in v0.2.1!
Make sure to always update to the latest version (npm i @mswjs/source@latest
) to get the newest features and bug fixes.
Predictable release automation by @ossjs/release.
Fixes #58