mirror of
https://github.com/shlinkio/shlink.git
synced 2025-03-29 04:52:54 +03:00
Added check for domain when matching an existing short URL
This commit is contained in:
parent
fd1fe90731
commit
25f64a2fc4
2 changed files with 9 additions and 6 deletions
|
@ -53,12 +53,7 @@ class ShortUrl extends AbstractEntity
|
||||||
$this->validUntil = $meta->getValidUntil();
|
$this->validUntil = $meta->getValidUntil();
|
||||||
$this->maxVisits = $meta->getMaxVisits();
|
$this->maxVisits = $meta->getMaxVisits();
|
||||||
$this->shortCode = $meta->getCustomSlug() ?? ''; // TODO logic to calculate short code should be passed somehow
|
$this->shortCode = $meta->getCustomSlug() ?? ''; // TODO logic to calculate short code should be passed somehow
|
||||||
$this->domain = $this->domainToEntity($meta->getDomain(), $domainResolver ?? new SimpleDomainResolver());
|
$this->domain = ($domainResolver ?? new SimpleDomainResolver())->resolveDomain($meta->getDomain());
|
||||||
}
|
|
||||||
|
|
||||||
private function domainToEntity(?string $domain, DomainResolverInterface $domainResolver): ?Domain
|
|
||||||
{
|
|
||||||
return $domainResolver->resolveDomain($domain);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLongUrl(): string
|
public function getLongUrl(): string
|
||||||
|
@ -170,6 +165,9 @@ class ShortUrl extends AbstractEntity
|
||||||
if ($meta->hasMaxVisits() && $meta->getMaxVisits() !== $this->maxVisits) {
|
if ($meta->hasMaxVisits() && $meta->getMaxVisits() !== $this->maxVisits) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if ($meta->hasDomain() && $meta->getDomain() !== $this->resolveDomain()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if ($meta->hasValidSince() && ! $meta->getValidSince()->eq($this->validSince)) {
|
if ($meta->hasValidSince() && ! $meta->getValidSince()->eq($this->validSince)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,6 +151,11 @@ final class ShortUrlMeta
|
||||||
return (bool) $this->findIfExists;
|
return (bool) $this->findIfExists;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function hasDomain(): bool
|
||||||
|
{
|
||||||
|
return $this->domain !== null;
|
||||||
|
}
|
||||||
|
|
||||||
public function getDomain(): ?string
|
public function getDomain(): ?string
|
||||||
{
|
{
|
||||||
return $this->domain;
|
return $this->domain;
|
||||||
|
|
Loading…
Add table
Reference in a new issue