`path` option is dropped from request URLs when it has no trailing slash
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 74/100
Research direction
The bug is in how channels_url_prefix() builds the Guzzle base_uri from the path option, and the relative request paths (apps/<app_id>/...) then resolve against it. Start by reproducing with 'path' => '/pusher' and checking the final request URL in the existing tests or a mocked client. Done means the prefix survives with and without a trailing slash for trigger, get, post and postAsync, with a test covering the no-slash case.
Written by the indexing model from the issue text.
Description
The README describes path as "a prefix to append to all request paths". When the value has no trailing slash, the library sends requests without the prefix and raises no error.
Steps to reproduce
$pusher = new Pusher\Pusher($key, $secret, $app_id, [
'host' => 'proxy.example.com',
'path' => '/pusher',
]);
$pusher->trigger('my-channel', 'my-event', 'hello');
Expected behavior
The request goes to https://proxy.example.com:443/pusher/apps/<app_id>/events.
Actual behavior
The request goes to https://proxy.example.com:443/apps/<app_id>/events. With 'path' => '/pusher/' the prefix is kept.
Cause
channels_url_prefix() returns scheme://host:port followed by path, and that value is passed to Guzzle as base_uri. Requests use a relative path (apps/<app_id>/..., see #335). Guzzle resolves that path against base_uri with RFC 3986 rules, which replace the last segment of the base path when it does not end with a slash. The same applies to get(), post() and postAsync().
Environment
pusher/pusher-php-server 7.3.0 (master 058d846), Guzzle 7, PHP 8.5.
- Dominant language
- PHP
- Stars
- 1.5k
- Forks
- 317
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pusher/pusher-http-php
-
getChannels() crashes on servers returning an empty channels array — the guard exists in process_trigger_result() but not herePossibly taken @mkantautas claimed this 11 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
pusher/pusher-http-php#408 ·
All issues in pusher/pusher-http-php
Similar issues
-
0. Needs triage 35-feedback bug
Difficulty 1/5 Under an hour Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
getgrav/grav-plugin-api#74 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
PrestaShopCorp/ps_eventbus#505 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
AuthorizationGuard::refreshUser() drops the decoded access token, so permission checks fail afterwardsPossibly taken @RaphaelFakhri claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
auth0/laravel-auth0#503 ·