mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-17 13:03:50 +00:00
21 lines
665 B
TypeScript
21 lines
665 B
TypeScript
import { isNil } from 'ramda';
|
|
import { ShortUrl } from '../data';
|
|
import { OptionalString } from '../../utils/utils';
|
|
import { DEFAULT_DOMAIN } from '../../visits/reducers/domainVisits';
|
|
|
|
export const shortUrlMatches = (shortUrl: ShortUrl, shortCode: string, domain: OptionalString): boolean => {
|
|
if (isNil(domain)) {
|
|
return shortUrl.shortCode === shortCode && !shortUrl.domain;
|
|
}
|
|
|
|
return shortUrl.shortCode === shortCode && shortUrl.domain === domain;
|
|
};
|
|
|
|
export const domainMatches = (shortUrl: ShortUrl, domain: string): boolean => {
|
|
if (!shortUrl.domain && domain === DEFAULT_DOMAIN) {
|
|
return true;
|
|
}
|
|
|
|
return shortUrl.domain === domain;
|
|
};
|