From 59edbe645ca568aa6438f8fa53c1a567cf1159c0 Mon Sep 17 00:00:00 2001 From: Julian <29632054+Parzival-3141@users.noreply.github.com> Date: Thu, 31 Aug 2023 17:36:03 -0700 Subject: `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... --- src/bun.js/bindings/BunString.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/bun.js/bindings/BunString.cpp') 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); -- cgit v1.2.3