Added forwardQuery prop to the SHortUrl serialization

This commit is contained in:
Alejandro Celaya 2021-10-02 10:31:23 +02:00
parent 74a08b86ce
commit e21f9dd1fb
5 changed files with 32 additions and 3 deletions

View File

@ -1,5 +1,18 @@
{
"type": "object",
"required": [
"shortCode",
"shortUrl",
"longUrl",
"dateCreated",
"visitsCount",
"tags",
"meta",
"domain",
"title",
"crawlable",
"forwardQuery"
],
"properties": {
"shortCode": {
"type": "string",
@ -45,6 +58,10 @@
"crawlable": {
"type": "boolean",
"description": "Tells if this URL will be included as 'Allow' in Shlink's robots.txt."
},
"forwardQuery": {
"type": "boolean",
"description": "Tells if this URL will forward the query params to the long URL when visited, as explained in [the docs](https://shlink.io/documentation/some-features/#query-params-forwarding)."
}
}
}

View File

@ -33,6 +33,7 @@ class ShortUrlDataTransformer implements DataTransformerInterface
'domain' => $shortUrl->getDomain(),
'title' => $shortUrl->title(),
'crawlable' => $shortUrl->crawlable(),
'forwardQuery' => $shortUrl->forwardQuery(),
];
}

View File

@ -60,6 +60,7 @@ class MercureUpdatesGeneratorTest extends TestCase
'domain' => null,
'title' => $title,
'crawlable' => false,
'forwardQuery' => true,
],
'visit' => [
'referer' => '',

View File

@ -27,6 +27,7 @@ class ListShortUrlsTest extends ApiTestCase
'domain' => null,
'title' => 'My cool title',
'crawlable' => true,
'forwardQuery' => true,
];
private const SHORT_URL_DOCS = [
'shortCode' => 'ghi789',
@ -43,6 +44,7 @@ class ListShortUrlsTest extends ApiTestCase
'domain' => null,
'title' => null,
'crawlable' => false,
'forwardQuery' => true,
];
private const SHORT_URL_CUSTOM_SLUG_AND_DOMAIN = [
'shortCode' => 'custom-with-domain',
@ -59,6 +61,7 @@ class ListShortUrlsTest extends ApiTestCase
'domain' => 'some-domain.com',
'title' => null,
'crawlable' => false,
'forwardQuery' => true,
];
private const SHORT_URL_META = [
'shortCode' => 'def456',
@ -77,6 +80,7 @@ class ListShortUrlsTest extends ApiTestCase
'domain' => null,
'title' => null,
'crawlable' => false,
'forwardQuery' => true,
];
private const SHORT_URL_CUSTOM_SLUG = [
'shortCode' => 'custom',
@ -93,6 +97,7 @@ class ListShortUrlsTest extends ApiTestCase
'domain' => null,
'title' => null,
'crawlable' => false,
'forwardQuery' => false,
];
private const SHORT_URL_CUSTOM_DOMAIN = [
'shortCode' => 'ghi789',
@ -111,6 +116,7 @@ class ListShortUrlsTest extends ApiTestCase
'domain' => 'example.com',
'title' => null,
'crawlable' => false,
'forwardQuery' => true,
];
/**

View File

@ -51,9 +51,13 @@ class ShortUrlsFixture extends AbstractFixture implements DependentFixtureInterf
]), $relationResolver), '2019-01-01 00:00:10');
$manager->persist($defShortUrl);
$customShortUrl = $this->setShortUrlDate(ShortUrl::fromMeta(ShortUrlMeta::fromRawData(
['customSlug' => 'custom', 'maxVisits' => 2, 'apiKey' => $authorApiKey, 'longUrl' => 'https://shlink.io'],
)), '2019-01-01 00:00:20');
$customShortUrl = $this->setShortUrlDate(ShortUrl::fromMeta(ShortUrlMeta::fromRawData([
'customSlug' => 'custom',
'maxVisits' => 2,
'apiKey' => $authorApiKey,
'longUrl' => 'https://shlink.io',
'forwardQuery' => false,
])), '2019-01-01 00:00:20');
$manager->persist($customShortUrl);
$ghiShortUrl = $this->setShortUrlDate(