Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/invoke.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function invoke(name, hash) {
}
if (/get[A-Z]([*]*)/.test(name)) {
options.method = 'GET';
url += `?payload=${body}`;
url += `?payload=${encodeURIComponent(body)}`;
} else {
options.body = body;
if (/patch[A-Z]([*]*)/.test(name)) {
Expand Down
8 changes: 8 additions & 0 deletions tests/src/ServerFunctions.njs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { readFileSync } from 'fs';
import Nullstack from 'nullstack';
import { clientOnly, serverOnly } from './helpers';

const decodedString = "! * ' ( ) ; : @ & = + $ , / ? % # [ ]"

class ServerFunctions extends Nullstack {

count = 0;
Expand Down Expand Up @@ -53,6 +55,10 @@ class ServerFunctions extends Nullstack {
return number * 2 + 1
}

static async getEncodedString({ string }) {
return string === decodedString
}

async initiate() {
this.statement = await this.useNodeFileSystem();
this.response = await this.useFetchInNode();
Expand All @@ -62,6 +68,7 @@ class ServerFunctions extends Nullstack {
async hydrate() {
this.clientOnly = clientOnly();
this.doublePlusOneClient = await ServerFunctions.getDoublePlusOne({ number: 34 })
this.acceptsSpecialCharacters = await this.getEncodedString({ string: decodedString })
}

render() {
Expand All @@ -77,6 +84,7 @@ class ServerFunctions extends Nullstack {
<div data-client-only={this.clientOnly} />
<div data-double-plus-one-server={this.doublePlusOneServer === 69} />
<div data-double-plus-one-client={this.doublePlusOneClient === 69} />
<div data-accepts-special-characters={this.acceptsSpecialCharacters} />
</div>
)
}
Expand Down
6 changes: 6 additions & 0 deletions tests/src/ServerFunctions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,10 @@ describe('ServerFunctions', () => {
expect(element).toBeTruthy();
});

test('get server functions can accept special characters', async () => {
await page.waitForSelector('[data-accepts-special-characters]');
const element = await page.$('[data-accepts-special-characters]');
expect(element).toBeTruthy();
});

});