-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement fetching data urls #4000
Conversation
❌ @dylan-conway 4 files with test failures on bun-darwin-aarch64:
|
❌ @dylan-conway 2 files with test failures on linux-x64-baseline:
|
❌ @dylan-conway 2 files with test failures on linux-x64:
|
❌ @dylan-conway 6 files with test failures on bun-darwin-x64-baseline:
|
src/bun.js/webcore/response.zig
Outdated
}, | ||
}, | ||
.allocator = allocator, | ||
.status_text = bun.String.create("OK"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createAtom
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or just .empty
src/resolver/data_url.zig
Outdated
@@ -71,22 +71,28 @@ pub const PercentEncoding = struct { | |||
} | |||
} | |||
|
|||
if (ret) |some| return allocator.shrink(some, ret_index); | |||
if (ret) |some| return allocator.realloc(some, ret_index) catch unreachable; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets just not reallocate i don't think its necessary
if (!strings.startsWith(url, "data:")) { | ||
return null; | ||
} | ||
|
||
const comma = strings.indexOfChar(url, ',') orelse return null; | ||
var result = try parseWithoutCheck(url); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return try parseWithoutCheck(url);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but it doesn't matter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's actually compiler error, not sure if it's a zig bug
@@ -34,7 +34,7 @@ pub const PercentEncoding = struct { | |||
if (comptime Environment.allow_assert) std.debug.assert(str.len > 0); | |||
return switch (str[0]) { | |||
'a'...'z', 'A'...'Z', '0'...'9', '-', '.', '_', '~', '!', '$', '&', '\'', '(', ')', '*', '+', ',', ';', '=', ':', '@' => true, | |||
'%' => str.len > 3 and isHex(str[1]) and isHex(str[2]), | |||
'%' => str.len >= 3 and isHex(str[1]) and isHex(str[2]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
* fetch data urls * `byteSlice` * deinit slice * allocate `mime_type` string if needed * `content_type_allocated` and uncomment tests * `str_` * createAtom and slice decode result
What does this PR do?
this adds support for fetching data urls
How did you verify your code works?
added tests for fetching valid and invalid data urls