Is there a way to overcome this limitation somehow?
Yes! and I'm really suprissed hardly anyone is talking about it!
thismessage: was designed exactly for this purpose!
The handling of relative and absolute URIs for matching between body parts have been merged into a single description, by specifying that relative URIs, which cannot be resolved otherwise, should be handled as if they had been given the URL "thismessage:/".
https://www.rfc-editor.org/rfc/rfc2557.html#section-12
When the methods above do not yield an absolute URI, a base URL of "thismessage:/" MUST be employed. This base URL has been defined for the sole purpose of resolving relative references within a multipart/related structure when no other base URI is specified.
https://www.rfc-editor.org/rfc/rfc2557.html#section-5
The concept is that first argument to the URL constructor is the path either absolute or relative and the second argument is the base URI to associate this to. We typically think of the base as something like https://example.com/ but that is not necessary especially when the URL we are building does not have any need for such a base.
let url = new URL('some/path/we/care/about', 'thismessage:/');
url.searchParams.set('foo', 'bar');
// 12 being the length of 'thismessage:'
let resultWithoutProtocol = url.href.substring(12);
document.querySelector('output').value = resultWithoutProtocol;
<code><output></output></code>
URLobject? Is it to extract the protocol, host etc?