Skip to content

Commit 3e1f509

Browse files
committed
Add query string to path
1 parent 10a54f4 commit 3e1f509

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/main/php/websocket/WebSocket.class.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public function __construct($endpoint, $origin= 'localhost') {
3535
$this->socket= new Socket($url['host'], $url['port'] ?? 80);
3636
}
3737
$this->path= $url['path'] ?? '/';
38+
isset($url['query']) && $this->path.= '?'.$url['query'];
3839
}
3940
$this->origin= $origin;
4041
}

src/test/php/websocket/unittest/WebSocketTest.class.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ public function path($url, $expected) {
2626
Assert::equals($expected, (new WebSocket($url))->path());
2727
}
2828

29+
#[Test, Values([['ws://example.com', '/'], ['ws://example.com/?test=1&l=de', '/?test=1&l=de']])]
30+
public function query($url, $expected) {
31+
Assert::equals($expected, (new WebSocket($url))->path());
32+
}
33+
2934
#[Test]
3035
public function default_origin() {
3136
Assert::equals('localhost', (new WebSocket('ws://example.com'))->origin());

0 commit comments

Comments
 (0)