Skip to content

Commit 9112a15

Browse files
committed
Try to always use file:// paths?
1 parent ca16ec0 commit 9112a15

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

Source/JavaScriptCore/runtime/CachedTypes.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,18 +1541,23 @@ class CachedMetadataTable : public CachedObject<UnlinkedMetadataTable> {
15411541

15421542
class CachedSourceOrigin : public CachedObject<SourceOrigin> {
15431543
public:
1544+
// Upstream WebKit stores sourceOrigin.url().string() and re-parses it
1545+
// on decode with URL({}, string). In Bun, source origins are always
1546+
// file paths constructed via fileURLWithFileSystemPath. On Windows,
1547+
// fileURLWithFileSystemPath produces a URL with a different internal
1548+
// host() than what re-parsing the same URL's string() gives (drive
1549+
// letter "B:" is treated as host). This breaks SourceCodeKey::operator==
1550+
// which compares host(). To avoid this, we store the file system path
1551+
// directly and reconstruct via fileURLWithFileSystemPath on decode,
1552+
// so both encode/decode and runtime use the same construction path.
15441553
void encode(Encoder& encoder, const SourceOrigin& sourceOrigin)
15451554
{
1546-
dataLogLnIf(Options::verboseDiskCache(), "[Disk Cache] CachedSourceOrigin encode: url='", sourceOrigin.url().string(), "' host='", sourceOrigin.url().host(), "'");
1547-
m_string.encode(encoder, sourceOrigin.url().string());
1555+
m_string.encode(encoder, sourceOrigin.url().fileSystemPath());
15481556
}
15491557

15501558
SourceOrigin decode(Decoder& decoder) const
15511559
{
1552-
String decodedString = m_string.decode(decoder);
1553-
URL decodedURL({ }, decodedString);
1554-
dataLogLnIf(Options::verboseDiskCache(), "[Disk Cache] CachedSourceOrigin decode: stored='", decodedString, "' decoded_host='", decodedURL.host(), "'");
1555-
return SourceOrigin { WTF::move(decodedURL) };
1560+
return SourceOrigin { URL::fileURLWithFileSystemPath(m_string.decode(decoder)) };
15561561
}
15571562

15581563
private:

0 commit comments

Comments
 (0)