From 4ae402c2f0c89249fc80227acc7d6948267dc47f Mon Sep 17 00:00:00 2001 From: Chris Bobbe Date: Tue, 22 Sep 2020 16:07:08 -0700 Subject: [PATCH] RealmScreen: Remove last use of `isValidUrl`. 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. --- flow-typed/npm/url-regex_vx.x.x.js | 33 ------------------------------ package.json | 1 - src/start/RealmScreen.js | 4 ++-- src/utils/url.js | 4 ---- yarn.lock | 18 ---------------- 5 files changed, 2 insertions(+), 58 deletions(-) delete mode 100644 flow-typed/npm/url-regex_vx.x.x.js diff --git a/flow-typed/npm/url-regex_vx.x.x.js b/flow-typed/npm/url-regex_vx.x.x.js deleted file mode 100644 index 2cda2054b50..00000000000 --- a/flow-typed/npm/url-regex_vx.x.x.js +++ /dev/null @@ -1,33 +0,0 @@ -// flow-typed signature: df09f4712c88101b041616a710df18d1 -// flow-typed version: <>/url-regex_v^4.1.1/flow_v0.92.0 - -/** - * This is an autogenerated libdef stub for: - * - * 'url-regex' - * - * Fill this stub out by replacing all the `any` types. - * - * Once filled out, we encourage you to share your work with the - * community by sending a pull request to: - * https://github.com/flowtype/flow-typed - */ - -declare module 'url-regex' { - declare module.exports: any; -} - -/** - * We include stubs for each file inside this npm package in case you need to - * require those files directly. Feel free to delete any files that aren't - * needed. - */ - - -// Filename aliases -declare module 'url-regex/index' { - declare module.exports: $Exports<'url-regex'>; -} -declare module 'url-regex/index.js' { - declare module.exports: $Exports<'url-regex'>; -} diff --git a/package.json b/package.json index b5d85a422e5..df483c36da6 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/start/RealmScreen.js b/src/start/RealmScreen.js index 73194af3606..edc6b169452 100644 --- a/src/start/RealmScreen.js +++ b/src/start/RealmScreen.js @@ -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'; @@ -131,7 +131,7 @@ class RealmScreen extends PureComponent { text="Enter" progress={progress} onPress={this.tryRealm} - disabled={!isValidUrl(realmInputValue)} + disabled={tryParseUrl(realmInputValue) === undefined} /> ); diff --git a/src/utils/url.js b/src/utils/url.js index bc06075992b..179a4ce1cc0 100644 --- a/src/utils/url.js +++ b/src/utils/url.js @@ -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'; @@ -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, diff --git a/yarn.lock b/yarn.lock index d4c426016de..df7594a0b04 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -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" @@ -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"