Skip to content

Commit

Permalink
Merge pull request #1156 from acelaya-forks/feature/query-num-keys
Browse files Browse the repository at this point in the history
Fixed numeric query params being replaced by 0 in long URLs
  • Loading branch information
acelaya authored Aug 15, 2021
2 parents ff6747d + 3e8ce80 commit 8393d44
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org).

## [2.8.1] - 2021-08-15
### Added
* *Nothing*

### Changed
* *Nothing*

### Deprecated
* *Nothing*

### Removed
* *Nothing*

### Fixed
* [#1155](https://github.com/shlinkio/shlink/issues/1155) Fixed numeric query params in long URLs being replaced by `0`.


## [2.8.0] - 2021-08-04
### Added
* [#1089](https://github.com/shlinkio/shlink/issues/1089) Added new `ENABLE_PERIODIC_VISIT_LOCATE` env var to docker image which schedules the `visit:locate` command every hour when provided with value `true`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
namespace Shlinkio\Shlink\Core\ShortUrl\Helper;

use GuzzleHttp\Psr7\Query;
use Laminas\Stdlib\ArrayUtils;
use League\Uri\Uri;
use Shlinkio\Shlink\Core\Entity\ShortUrl;
use Shlinkio\Shlink\Core\Options\TrackingOptions;

use function array_merge;
use function sprintf;

class ShortUrlRedirectionBuilder implements ShortUrlRedirectionBuilderInterface
Expand Down Expand Up @@ -37,7 +37,8 @@ private function resolveQuery(Uri $uri, array $currentQuery): ?string
unset($currentQuery[$disableTrackParam]);
}

$mergedQuery = array_merge($hardcodedQuery, $currentQuery);
// We want to merge preserving numeric keys, as some params might be numbers
$mergedQuery = ArrayUtils::merge($hardcodedQuery, $currentQuery, true);

return empty($mergedQuery) ? null : Query::build($mergedQuery);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public function provideData(): iterable
yield ['https://domain.com/foo/bar?some=thing', [], null];
yield ['https://domain.com/foo/bar?some=thing&else', ['else' => null], null];
yield ['https://domain.com/foo/bar?some=thing&foo=bar', ['foo' => 'bar'], null];
yield ['https://domain.com/foo/bar?some=thing&123=foo', ['123' => 'foo'], null];
yield ['https://domain.com/foo/bar?some=thing&456=foo', [456 => 'foo'], null];
yield ['https://domain.com/foo/bar?some=overwritten&foo=bar', ['foo' => 'bar', 'some' => 'overwritten'], null];
yield ['https://domain.com/foo/bar?some=overwritten', ['foobar' => 'notrack', 'some' => 'overwritten'], null];
yield ['https://domain.com/foo/bar/something/else-baz?some=thing', [], '/something/else-baz'];
Expand Down

0 comments on commit 8393d44

Please sign in to comment.