diff --git a/internal_packages/onboarding/lib/account-settings-page.cjsx b/internal_packages/onboarding/lib/account-settings-page.cjsx index 3eab3ee5d..f06747e0a 100644 --- a/internal_packages/onboarding/lib/account-settings-page.cjsx +++ b/internal_packages/onboarding/lib/account-settings-page.cjsx @@ -2,7 +2,7 @@ React = require 'react' _ = require 'underscore' {ipcRenderer, dialog, remote} = require 'electron' {RetinaImg} = require 'nylas-component-kit' -{EdgehillAPI, NylasAPI, APIError, Actions} = require 'nylas-exports' +{RegExpUtils, EdgehillAPI, NylasAPI, APIError, Actions} = require 'nylas-exports' OnboardingActions = require './onboarding-actions' NylasApiEnvironmentStore = require './nylas-api-environment-store' @@ -190,8 +190,26 @@ class AccountSettingsPage extends React.Component _renderErrorMessage: => - if @state.errorMessage -
{@state.errorMessage ? ""}
+ return unless @state.errorMessage + + text = @state.errorMessage + result = RegExpUtils.urlRegex(matchEntireString: false).exec(text) + + if result + link = result[0] + beforeText = text.substr(0, result.index) + afterText = text.substr(result.index + link.length) + return ( +
+ {beforeText}{link}{afterText} +
+ ) + else + return ( +
+ {text} +
+ ) _fieldOnCurrentPage: (field) => !@state.provider.pages || field.page is @state.pageNumber diff --git a/internal_packages/onboarding/stylesheets/onboarding.less b/internal_packages/onboarding/stylesheets/onboarding.less index c07ad6fbc..4044339e3 100644 --- a/internal_packages/onboarding/stylesheets/onboarding.less +++ b/internal_packages/onboarding/stylesheets/onboarding.less @@ -230,6 +230,9 @@ .errormsg { color: #A33; margin-bottom:5px; + a { + color: #A33; + } } form.settings { diff --git a/src/components/contenteditable/link-editor.cjsx b/src/components/contenteditable/link-editor.cjsx index 8a33dd758..21abdbdf5 100644 --- a/src/components/contenteditable/link-editor.cjsx +++ b/src/components/contenteditable/link-editor.cjsx @@ -106,8 +106,9 @@ class LinkEditor extends React.Component _initialUrl: (props=@props) => initialUrl = props.linkToModify?.getAttribute('href') ? "" if initialUrl.length is 0 - if RegExpUtils.urlRegex().test(props.linkToModify?.textContent ? "") - initialUrl = props.linkToModify.textContent ? "" + textContent = props.linkToModify?.textContent ? "" + if RegExpUtils.urlRegex(matchEntireString: true).test(textContent) + initialUrl = textContent return initialUrl diff --git a/src/regexp-utils.coffee b/src/regexp-utils.coffee index cc4ad4c3a..acb22f53d 100644 --- a/src/regexp-utils.coffee +++ b/src/regexp-utils.coffee @@ -23,7 +23,11 @@ RegExpUtils = # http://daringfireball.net/2010/07/improved_regex_for_matching_urls # https://mathiasbynens.be/demo/url-regex # This is the Gruber Regex. - urlRegex: -> new RegExp(/^\b((?:https?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))$/) + urlRegex: ({matchEntireString} = {}) -> + if matchEntireString + new RegExp(/^\b((?:https?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))$/) + else + new RegExp(/\b((?:https?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))$/) # Test cases: https://regex101.com/r/jD5zC7/2 # Returns the following capturing groups: