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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
php-version: ['8.4', '8.5']
shlink-version: ['5.0', '4.6', '4.5', '4.4', '4.3', '4.2', '4.1', '4.0']
shlink-version: ['5.1', '5.0', '4.6', '4.5', '4.4', '4.3', '4.2', '4.1', '4.0']
shlink-api-version: ['3']
steps:
- name: Checkout code
Expand Down
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).

## [3.3.0] - 2026-06-12
### Added
* Add support for `browser` redirect conditions, which were introduced in Shlink 5.1.0

### Changed
* *Nothing*

### Deprecated
* *Nothing*

### Removed
* *Nothing*

### Fixed
* *Nothing*


## [3.2.0] - 2026-05-22
### Added
* *Nothing*
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM composer:2

COPY --from=ghcr.io/php/pie:bin /pie /usr/bin/pie
RUN apk add --update linux-headers && \
apk add --no-cache --virtual .phpize-deps ${PHPIZE_DEPS} && \
pecl install xdebug && \
docker-php-ext-enable xdebug && \
pie install xdebug/xdebug && \
apk del .phpize-deps
6 changes: 6 additions & 0 deletions src/RedirectRules/Model/RedirectCondition.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use DateTimeInterface;
use JsonSerializable;
use Shlinkio\Shlink\SDK\ShortUrls\Model\Browser;
use Shlinkio\Shlink\SDK\ShortUrls\Model\Device;

final readonly class RedirectCondition implements JsonSerializable
Expand Down Expand Up @@ -71,6 +72,11 @@ public static function forAfterDate(DateTimeInterface $date): self
return new self(RedirectConditionType::AFTER_DATE, $date->format(DateTimeInterface::ATOM));
}

public static function forBrowser(Browser $browser): self
{
return new self(RedirectConditionType::BROWSER, $browser->value);
}

public static function fromArray(array $payload): self
{
$originalType = $payload['type'] ?? '';
Expand Down
1 change: 1 addition & 0 deletions src/RedirectRules/Model/RedirectConditionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ enum RedirectConditionType: string
case GEOLOCATION_CITY_NAME = 'geolocation-city-name';
case BEFORE_DATE = 'before-date';
case AFTER_DATE = 'after-date';
case BROWSER = 'browser';
case UNKNOWN = 'unknown';
}
15 changes: 15 additions & 0 deletions src/ShortUrls/Model/Browser.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

namespace Shlinkio\Shlink\SDK\ShortUrls\Model;

enum Browser: string
{
case CHROME = 'chrome';
case FIREFOX = 'firefox';
case EDGE = 'edge';
case SAFARI = 'safari';
case OPERA = 'opera';
case ANDROID_BROWSER = 'android_browser';
}
11 changes: 11 additions & 0 deletions test/RedirectRules/Model/RedirectConditionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use PHPUnit\Framework\TestCase;
use Shlinkio\Shlink\SDK\RedirectRules\Model\RedirectCondition;
use Shlinkio\Shlink\SDK\RedirectRules\Model\RedirectConditionType;
use Shlinkio\Shlink\SDK\ShortUrls\Model\Browser;
use Shlinkio\Shlink\SDK\ShortUrls\Model\Device;

class RedirectConditionTest extends TestCase
Expand Down Expand Up @@ -97,6 +98,16 @@ public function forDeviceCreatesExpectedCondition(): void
self::assertNull($condition->matchKey);
}

#[Test]
public function forBrowserCreatesExpectedCondition(): void
{
$condition = RedirectCondition::forBrowser(Browser::CHROME);

self::assertEquals(RedirectConditionType::BROWSER, $condition->type);
self::assertEquals(Browser::CHROME->value, $condition->matchValue);
self::assertNull($condition->matchKey);
}

#[Test]
public function forIpAddressCreatesExpectedCondition(): void
{
Expand Down
Loading