mirror of
https://github.com/bigskysoftware/htmx.git
synced 2026-01-25 05:06:13 +00:00
This commit is contained in:
@@ -723,7 +723,9 @@ var htmx = (() => {
|
||||
if (colonIndex <= 0) continue;
|
||||
|
||||
let field = line.slice(0, colonIndex);
|
||||
let value = line.slice(colonIndex + 1).trimStart();
|
||||
|
||||
let value = line.slice(colonIndex + 1)
|
||||
if (value[0] === ' ') value = value.slice(1);
|
||||
|
||||
if (field === 'data') {
|
||||
message.data += (message.data ? '\n' : '') + value;
|
||||
|
||||
@@ -458,4 +458,22 @@ describe('Server-Sent Events', function() {
|
||||
|
||||
stream.close();
|
||||
});
|
||||
|
||||
it('only trims single space after colon', async function() {
|
||||
const stream = mockStreamResponse('/sse-whitespace');
|
||||
createProcessedHTML('<button id="ws-btn" hx-get="/sse-whitespace" hx-swap="innerHTML">Whitespace</button>');
|
||||
|
||||
find('#ws-btn').click();
|
||||
await htmx.timeout(1);
|
||||
|
||||
stream.send(' \ttext-with-two-leading-spaces');
|
||||
await waitForEvent('htmx:after:sse:message');
|
||||
assertTextContentIs('#ws-btn', ' \ttext-with-two-leading-spaces');
|
||||
|
||||
stream.send('NoTrim');
|
||||
await waitForEvent('htmx:after:sse:message');
|
||||
assertTextContentIs('#ws-btn', 'NoTrim');
|
||||
|
||||
stream.close();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user