Skip to content

Commit

Permalink
perf fix, simple back on
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisnojima committed Dec 3, 2018
1 parent 522e4e2 commit ec71fb1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
21 changes: 13 additions & 8 deletions shared/common-adapters/markdown/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,25 @@ function parseMarkdown(
}
}

const _makeLinkRegex = () => {
const valid = `[:,!]*[\\w=#%~\\-_~&@+\\u00c0-\\uffff]`
const paranthesisPaired = `([(]${valid}+[)])`
const afterDomain = `(?:\\/|${paranthesisPaired}|${valid}|[.?]+[\\w/=])`
return new RegExp(
`^( *)((https?:\\/\\/)?[\\w-]+(\\.[\\w-]+)+(:\\d+)?((?:\\/|\\?[\\w=])${afterDomain}*)?)`,
'i'
)
}

const _linkRegex = _makeLinkRegex()

// TODO, when named groups are supported on mobile, we can use this instead
// const linkRegex = /^( *)((https?:\/\/)?[\w-]+(?<tld>\.[\w-]+)+\.?(:\d+)?(\/\S*)?)\b/i
// This copies the functionality of this named group
// $FlowIssue treat this like a RegExp
const linkRegex: RegExp = {
exec: source => {
const valid = `[:,!]*[\\w=#%~\\-_~&@+\\u00c0-\\uffff]`
const paranthesisPaired = `([(]${valid}+[)])`
const afterDomain = `(?:\\/|${paranthesisPaired}|${valid}|[.?]+[\\w/=])`
const r = new RegExp(
`^( *)((https?:\\/\\/)?[\\w-]+(\\.[\\w-]+)+(:\\d+)?((?:\\/|\\?[\\w=])${afterDomain}*)?)`,
'i'
)
const result = r.exec(source)
const result = _linkRegex.exec(source)
if (result) {
result.groups = {tld: result[4]}
return result
Expand Down
3 changes: 1 addition & 2 deletions shared/util/feature-flags.desktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ const ff: FeatureFlags = {
newTeamBuildingForChatAllowMakeTeam: false,
outOfDateBanner: false,
plansEnabled: false,
useSimpleMarkdown: false,
useSimpleMarkdown: true,
walletsEnabled: false,
}

const inAdmin: {[key: $Keys<FeatureFlags>]: boolean} = {
chatIndexProfilingEnabled: true,
moveOrCopy: true,
useSimpleMarkdown: true,
walletsEnabled: true,
}

Expand Down
2 changes: 1 addition & 1 deletion shared/util/feature-flags.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const ff: FeatureFlags = {
newTeamBuildingForChatAllowMakeTeam: false,
outOfDateBanner: false,
plansEnabled: false,
useSimpleMarkdown: false,
useSimpleMarkdown: true,
walletsEnabled: false,
}

Expand Down

0 comments on commit ec71fb1

Please sign in to comment.