diff --git a/src/servers/helpers/ForServerVersion.js b/src/servers/helpers/ForServerVersion.js index 0c51b22a..0b3c6fba 100644 --- a/src/servers/helpers/ForServerVersion.js +++ b/src/servers/helpers/ForServerVersion.js @@ -1,7 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { serverType } from '../prop-types'; -import { compareVersions } from '../../utils/helpers/version'; +import { versionMatch } from '../../utils/helpers/version'; const propTypes = { minVersion: PropTypes.string, @@ -16,10 +16,9 @@ const ForServerVersion = ({ minVersion, maxVersion, selectedServer, children }) } const { version } = selectedServer; - const matchesMinVersion = !minVersion || compareVersions(version, '>=', minVersion); - const matchesMaxVersion = !maxVersion || compareVersions(version, '<=', maxVersion); + const matchesVersion = versionMatch(version, { maxVersion, minVersion }); - if (!matchesMinVersion || !matchesMaxVersion) { + if (!matchesVersion) { return null; } diff --git a/src/short-urls/CreateShortUrl.js b/src/short-urls/CreateShortUrl.js index e1719fe3..aa1926df 100644 --- a/src/short-urls/CreateShortUrl.js +++ b/src/short-urls/CreateShortUrl.js @@ -7,7 +7,8 @@ import * as PropTypes from 'prop-types'; import DateInput from '../utils/DateInput'; import Checkbox from '../utils/Checkbox'; import { serverType } from '../servers/prop-types'; -import { compareVersions } from '../utils/helpers/version'; +import { versionMatch } from '../utils/helpers/version'; +import { hasValue } from '../utils/utils'; import { createShortUrlResultType } from './reducers/shortUrlCreation'; import UseExistingIfFoundInfoIcon from './UseExistingIfFoundInfoIcon'; @@ -30,6 +31,7 @@ const CreateShortUrl = ( longUrl: '', tags: [], customSlug: undefined, + shortCodeLength: undefined, domain: undefined, validSince: undefined, validUntil: undefined, @@ -73,8 +75,9 @@ const CreateShortUrl = ( assoc('validUntil', formatDate(this.state.validUntil)) )(this.state)); }; - const currentServerVersion = this.props.selectedServer ? this.props.selectedServer.version : ''; - const disableDomain = isEmpty(currentServerVersion) || compareVersions(currentServerVersion, '<', '1.19.0-beta.1'); + const currentServerVersion = this.props.selectedServer && this.props.selectedServer.version; + const disableDomain = !versionMatch(currentServerVersion, { minVersion: '1.19.0-beta.1' }); + const disableShortCodeLength = !versionMatch(currentServerVersion, { minVersion: '2.1.0' }); return (