diff options
Diffstat (limited to 'src/bun.js/bindings/BunString.cpp')
-rw-r--r-- | src/bun.js/bindings/BunString.cpp | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/src/bun.js/bindings/BunString.cpp b/src/bun.js/bindings/BunString.cpp index 416d5d334..31b331111 100644 --- a/src/bun.js/bindings/BunString.cpp +++ b/src/bun.js/bindings/BunString.cpp @@ -190,22 +190,6 @@ BunString toStringRef(WTF::StringImpl* wtfString) return { BunStringTag::WTFStringImpl, { .wtf = wtfString } }; } -BunString fromString(WTF::String& wtfString) -{ - if (wtfString.isEmpty()) - return { BunStringTag::Empty }; - - return { BunStringTag::WTFStringImpl, { .wtf = wtfString.impl() } }; -} - -BunString fromString(WTF::StringImpl* wtfString) -{ - if (wtfString->isEmpty()) - return { BunStringTag::Empty }; - - return { BunStringTag::WTFStringImpl, { .wtf = wtfString } }; -} - } extern "C" JSC::EncodedJSValue BunString__toJS(JSC::JSGlobalObject* globalObject, BunString* bunString) @@ -252,7 +236,7 @@ extern "C" BunString BunString__fromUTF8(const char* bytes, size_t length) auto str = WTF::String::fromUTF8ReplacingInvalidSequences(reinterpret_cast<const LChar*>(bytes), length); str.impl()->ref(); - return Bun::fromString(str); + return Bun::toString(str); } extern "C" BunString BunString__fromLatin1(const char* bytes, size_t length) @@ -381,7 +365,17 @@ extern "C" BunString URL__getHref(BunString* input) return Bun::toStringRef(url.string()); } -extern "C" BunString URL__getHrefJoin(BunString* baseStr, BunString *relativeStr) +extern "C" BunString URL__pathFromFileURL(BunString* input) +{ + auto&& str = Bun::toWTFString(*input); + auto url = WTF::URL(str); + if (!url.isValid() || url.isEmpty()) + return { BunStringTag::Dead }; + + return Bun::toStringRef(url.fileSystemPath()); +} + +extern "C" BunString URL__getHrefJoin(BunString* baseStr, BunString* relativeStr) { auto base = Bun::toWTFString(*baseStr); auto relative = Bun::toWTFString(*relativeStr); @@ -455,4 +449,4 @@ extern "C" uint32_t URL__port(WTF::URL* url) extern "C" BunString URL__pathname(WTF::URL* url) { return Bun::toStringRef(url->path().toStringWithoutCopying()); -}
\ No newline at end of file +} |