mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-07-30 17:25:58 -04:00
Merge pull request #2975 from lightpanda-io/eventsoruce-relative
Fix: Allow EventSource with relative URLs
This commit is contained in:
@@ -49,6 +49,23 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<script id=relative_url type=module>
|
||||
{
|
||||
const state = await testing.async();
|
||||
const es = new EventSource('/sse/simple');
|
||||
testing.expectEqual('http://127.0.0.1:9582/sse/simple', es.url);
|
||||
es.onerror = () => { throw new Error('unexpected error'); };
|
||||
es.onmessage = (e) => {
|
||||
es.close();
|
||||
state.resolve(e.data);
|
||||
};
|
||||
|
||||
await state.done((data) => {
|
||||
testing.expectEqual('first', data);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<script id=streaming type=module>
|
||||
{
|
||||
// The server only sends "second" after seeing our /sse/flag request, which
|
||||
|
||||
@@ -116,7 +116,7 @@ pub fn init(url: []const u8, opts_: ?Opts, exec: *const Execution) !*EventSource
|
||||
log.debug(.http, "EventSource connecting", .{ .url = resolved });
|
||||
}
|
||||
|
||||
if (std.ascii.startsWithIgnoreCase(url, "http://") == false and std.ascii.startsWithIgnoreCase(url, "https://") == false) {
|
||||
if (std.ascii.startsWithIgnoreCase(resolved, "http://") == false and std.ascii.startsWithIgnoreCase(resolved, "https://") == false) {
|
||||
try self.scheduleTask(failConnection, 0, "EventSource.fail");
|
||||
return self;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user