Skip to content

Commit

Permalink
RealmScreen: Remove last use of isValidUrl.
Browse files Browse the repository at this point in the history
And use a URL computation instead, which is what we do elsewhere. In
particular, it's how we check whether we can store the realm in
Redux, so it's good to make the UI align with that. This helper
function is a relic from the days before #4081 and #4146, so it
should disappear anyway.

It was the sole user of an NPM package. So, uninstall that.
  • Loading branch information
chrisbobbe committed Sep 22, 2020
1 parent 4efb34f commit 365e669
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 58 deletions.
33 changes: 0 additions & 33 deletions flow-typed/npm/url-regex_vx.x.x.js

This file was deleted.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@
"rn-fetch-blob": "^0.11.0",
"string.fromcodepoint": "^0.2.1",
"timezone": "^1.0.13",
"url-regex": "^4.1.1",
"zulip-markdown-parser": "^1.0.6"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions src/start/RealmScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ZulipVersion } from '../utils/zulipVersion';
import type { ApiResponseServerSettings, Dispatch } from '../types';
import { connect } from '../react-redux';
import { ErrorMsg, Label, SmartUrlInput, Screen, ZulipButton } from '../common';
import { isValidUrl, tryParseUrl } from '../utils/url';
import { tryParseUrl } from '../utils/url';
import * as api from '../api';
import { realmAdd, navigateToAuth } from '../actions';

Expand Down Expand Up @@ -131,7 +131,7 @@ class RealmScreen extends PureComponent<Props, State> {
text="Enter"
progress={progress}
onPress={this.tryRealm}
disabled={!isValidUrl(realmInputValue)}
disabled={tryParseUrl(realmInputValue) === undefined}
/>
</Screen>
);
Expand Down
4 changes: 0 additions & 4 deletions src/utils/url.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/* @flow strict-local */
import urlRegex from 'url-regex';

import type { Auth } from '../types';
import { getAuthHeaders } from '../api/transport';
import objectEntries from './objectEntries';
Expand Down Expand Up @@ -115,8 +113,6 @@ const mimes = {
export const getMimeTypeFromFileExtension = (extension: string): string =>
mimes[extension.toLowerCase()] || 'application/octet-stream';

export const isValidUrl = (url: string): boolean => urlRegex({ exact: true }).test(url);

export type AutocompletionDefaults = {|
protocol: Protocol,
domain: string,
Expand Down
18 changes: 0 additions & 18 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6161,11 +6161,6 @@ invert-kv@^2.0.0:
resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-2.0.0.tgz#7393f5afa59ec9ff5f67a27620d11c226e3eec02"
integrity sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA==

ip-regex@^1.0.1:
version "1.0.3"
resolved "https://registry.yarnpkg.com/ip-regex/-/ip-regex-1.0.3.tgz#dc589076f659f419c222039a33316f1c7387effd"
integrity sha1-3FiQdvZZ9BnCIgOaMzFvHHOH7/0=

ip-regex@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/ip-regex/-/ip-regex-2.1.0.tgz#fa78bf5d2e6913c911ce9f819ee5146bb6d844e9"
Expand Down Expand Up @@ -11365,11 +11360,6 @@ tinycolor2@^1.4.1:
resolved "https://registry.yarnpkg.com/tinycolor2/-/tinycolor2-1.4.1.tgz#f4fad333447bc0b07d4dc8e9209d8f39a8ac77e8"
integrity sha1-9PrTM0R7wLB9TcjpIJ2POaisd+g=

tlds@^1.187.0:
version "1.203.1"
resolved "https://registry.yarnpkg.com/tlds/-/tlds-1.203.1.tgz#4dc9b02f53de3315bc98b80665e13de3edfc1dfc"
integrity sha512-7MUlYyGJ6rSitEZ3r1Q1QNV8uSIzapS8SmmhSusBuIc7uIxPPwsKllEP0GRp1NS6Ik6F+fRZvnjDWm3ecv2hDw==

tmp@^0.0.33:
version "0.0.33"
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9"
Expand Down Expand Up @@ -11748,14 +11738,6 @@ url-parse@^1.4.4:
querystringify "^2.1.1"
requires-port "^1.0.0"

url-regex@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/url-regex/-/url-regex-4.1.1.tgz#a5617b22e15e26dac57ce74c3f52088bcdfec995"
integrity sha512-ViSDgDPNKkrQHI81GLCjdDN+Rsk3tAW/uLXlBOJxtcHzWZjta58Z0APXhfXzS89YszsheMnEvXeDXsWUB53wwA==
dependencies:
ip-regex "^1.0.1"
tlds "^1.187.0"

url-to-options@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/url-to-options/-/url-to-options-1.0.1.tgz#1505a03a289a48cbd7a434efbaeec5055f5633a9"
Expand Down

0 comments on commit 365e669

Please sign in to comment.