Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecated validateUrl option on short URL creation/edition #1679

Merged
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this
* *Nothing*

### Deprecated
* [#1676](https://github.com/shlinkio/shlink/issues/1676) Deprecated `GET /short-urls/shorten` endpoint. Use `POST /short-urls` to create short URLs instead
* [#1676](https://github.com/shlinkio/shlink/issues/1676) Deprecated `GET /short-urls/shorten` endpoint. Use `POST /short-urls` to create short URLs instead.
* [#1678](https://github.com/shlinkio/shlink/issues/1678) Deprecated `validateUrl` option on URL creation/edition.

### Removed
* *Nothing*
Expand Down
3 changes: 2 additions & 1 deletion docs/swagger/definitions/ShortUrlEdition.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"nullable": true
},
"validateUrl": {
"description": "Tells if the long URL (if provided) should or should not be validated as a reachable URL. If not provided, it will fall back to app-level config",
"deprecated": true,
"description": "**[DEPRECATED]** Tells if the long URL should or should not be validated as a reachable URL. Defaults to `false`",
"type": "boolean"
},
"tags": {
Expand Down
4 changes: 0 additions & 4 deletions docs/swagger/paths/v1_short-urls.json
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,6 @@
"shortCodeLength": {
"description": "The length for generated short code. It has to be at least 4 and defaults to 5. It will be ignored when customSlug is provided",
"type": "number"
},
"validateUrl": {
"description": "Tells if the long URL should or should not be validated as a reachable URL. If not provided, it will fall back to app-level config",
"type": "boolean"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion module/CLI/src/Command/ShortUrl/CreateShortUrlCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected function configure(): void
'validate-url',
null,
InputOption::VALUE_NONE,
'Forces the long URL to be validated, regardless what is globally configured.',
'[DEPRECATED] Makes the URL to be validated as publicly accessible.',
)
->addOption(
'crawlable',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public function __construct(private readonly UrlValidatorInterface $urlValidator
}

/**
* @deprecated TODO Rename to processTitle once URL validation is removed with Shlink 4.0.0
* Move relevant logic from URL validator here.
* @template T of TitleResolutionModelInterface
* @param T $data
* @return T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
interface ShortUrlTitleResolutionHelperInterface
{
/**
* @deprecated TODO Rename to processTitle once URL validation is removed with Shlink 4.0.0
* @template T of TitleResolutionModelInterface
* @param T $data
* @return T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public function hasTitle(): bool;

public function getLongUrl(): string;

/** @deprecated */
public function doValidateUrl(): bool;

public function withResolvedTitle(string $title): static;
Expand Down
2 changes: 2 additions & 0 deletions module/Core/src/ShortUrl/Model/ShortUrlCreation.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ private function __construct(
public readonly bool $findIfExists = false,
public readonly ?string $domain = null,
public readonly int $shortCodeLength = 5,
/** @deprecated */
public readonly bool $validateUrl = false,
public readonly ?ApiKey $apiKey = null,
public readonly array $tags = [],
Expand Down Expand Up @@ -131,6 +132,7 @@ public function hasDomain(): bool
return $this->domain !== null;
}

/** @deprecated */
public function doValidateUrl(): bool
{
return $this->validateUrl;
Expand Down
2 changes: 2 additions & 0 deletions module/Core/src/ShortUrl/Model/ShortUrlEdition.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ private function __construct(
private readonly bool $titlePropWasProvided = false,
public readonly ?string $title = null,
public readonly bool $titleWasAutoResolved = false,
/** @deprecated */
public readonly bool $validateUrl = false,
private readonly bool $crawlablePropWasProvided = false,
public readonly bool $crawlable = false,
Expand Down Expand Up @@ -154,6 +155,7 @@ public function titleWasAutoResolved(): bool
return $this->titleWasAutoResolved;
}

/** @deprecated */
public function doValidateUrl(): bool
{
return $this->validateUrl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class ShortUrlInputFilter extends InputFilter
public const SHORT_CODE_LENGTH = 'shortCodeLength';
public const LONG_URL = 'longUrl';
public const DEVICE_LONG_URLS = 'deviceLongUrls';
/** @deprecated */
public const VALIDATE_URL = 'validateUrl';
public const API_KEY = 'apiKey';
public const TAGS = 'tags';
Expand Down
6 changes: 6 additions & 0 deletions module/Core/src/Util/UrlValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

use const Shlinkio\Shlink\TITLE_TAG_VALUE;

/** @deprecated */
class UrlValidator implements UrlValidatorInterface, RequestMethodInterface
{
private const MAX_REDIRECTS = 15;
Expand All @@ -33,6 +34,7 @@ public function __construct(private ClientInterface $httpClient, private UrlShor
}

/**
* @deprecated
* @throws InvalidUrlException
*/
public function validateUrl(string $url, bool $doValidate): void
Expand All @@ -44,6 +46,10 @@ public function validateUrl(string $url, bool $doValidate): void
$this->validateUrlAndGetResponse($url);
}

/**
* @deprecated
* @throws InvalidUrlException
*/
public function validateUrlWithTitle(string $url, bool $doValidate): ?string
{
if (! $doValidate && ! $this->options->autoResolveTitles) {
Expand Down
3 changes: 3 additions & 0 deletions module/Core/src/Util/UrlValidatorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@

use Shlinkio\Shlink\Core\Exception\InvalidUrlException;

/** @deprecated */
interface UrlValidatorInterface
{
/**
* @deprecated
* @throws InvalidUrlException
*/
public function validateUrl(string $url, bool $doValidate): void;

/**
* @deprecated
* @throws InvalidUrlException
*/
public function validateUrlWithTitle(string $url, bool $doValidate): ?string;
Expand Down