diff options
author | 2023-08-31 17:36:03 -0700 | |
---|---|---|
committer | 2023-08-31 17:36:03 -0700 | |
commit | 59edbe645ca568aa6438f8fa53c1a567cf1159c0 (patch) | |
tree | e502880925967f03ce694537a14f4695809da62c /src/bun.js/bindings/BunString.cpp | |
parent | fef70f2473daefe242c80b9f3f34ef67396efaef (diff) | |
download | bun-59edbe645ca568aa6438f8fa53c1a567cf1159c0.tar.gz bun-59edbe645ca568aa6438f8fa53c1a567cf1159c0.tar.zst bun-59edbe645ca568aa6438f8fa53c1a567cf1159c0.zip |
`bun install` correctly join dependency URLs (#4421)
* use WTF to join registry strings
* show dependency error messages, better join error
We actually report errors when enqueuing dependencies now. I also made
the join URLs error message read better. It'd be cleaner to handle it
all in one place, but there's currently no way to propagate the data up.
* starting on registry URL tests
* added more registry URL tests
* [install] prevent optional/peer deps from failing builds
Couldn't get the peer dependency test to work, but the code is there.
* ran prettier
* changed error note to use realname, updated tests
* ran prettier again...
Diffstat (limited to 'src/bun.js/bindings/BunString.cpp')
-rw-r--r-- | src/bun.js/bindings/BunString.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/bun.js/bindings/BunString.cpp b/src/bun.js/bindings/BunString.cpp index 8c5a1e66b..416d5d334 100644 --- a/src/bun.js/bindings/BunString.cpp +++ b/src/bun.js/bindings/BunString.cpp @@ -381,6 +381,17 @@ extern "C" BunString URL__getHref(BunString* input) return Bun::toStringRef(url.string()); } +extern "C" BunString URL__getHrefJoin(BunString* baseStr, BunString *relativeStr) +{ + auto base = Bun::toWTFString(*baseStr); + auto relative = Bun::toWTFString(*relativeStr); + auto url = WTF::URL(WTF::URL(base), relative); + if (!url.isValid() || url.isEmpty()) + return { BunStringTag::Dead }; + + return Bun::toStringRef(url.string()); +} + extern "C" WTF::URL* URL__fromString(BunString* input) { auto&& str = Bun::toWTFString(*input); |