Skip to content

Commit 225f6df

Browse files
committed
fix(ios): linkRegex init before initial default value
1 parent 056004f commit 225f6df

2 files changed

Lines changed: 10 additions & 20 deletions

File tree

ios/EnrichedTextInputView.mm

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,15 @@ - (void)updateProps:(Props::Shared const &)props
719719
textShortcuts = shortcuts;
720720
}
721721

722+
// linkRegex
723+
LinkRegexConfig *oldRegexConfig =
724+
[[LinkRegexConfig alloc] initWithLinkRegexProp:oldViewProps.linkRegex];
725+
LinkRegexConfig *newRegexConfig =
726+
[[LinkRegexConfig alloc] initWithLinkRegexProp:newViewProps.linkRegex];
727+
if (![newRegexConfig isEqualToConfig:oldRegexConfig]) {
728+
[config setLinkRegexConfig:newRegexConfig];
729+
}
730+
722731
// default value - must be set before placeholder to make sure it correctly
723732
// shows on first mount
724733
if (newViewProps.defaultValue != oldViewProps.defaultValue) {
@@ -775,15 +784,6 @@ - (void)updateProps:(Props::Shared const &)props
775784
[config setMentionIndicators:newIndicators];
776785
}
777786

778-
// linkRegex
779-
LinkRegexConfig *oldRegexConfig =
780-
[[LinkRegexConfig alloc] initWithLinkRegexProp:oldViewProps.linkRegex];
781-
LinkRegexConfig *newRegexConfig =
782-
[[LinkRegexConfig alloc] initWithLinkRegexProp:newViewProps.linkRegex];
783-
if (![newRegexConfig isEqualToConfig:oldRegexConfig]) {
784-
[config setLinkRegexConfig:newRegexConfig];
785-
}
786-
787787
// selection color sets both selection and cursor on iOS (just as in RN)
788788
if (newViewProps.selectionColor != oldViewProps.selectionColor) {
789789
if (isColorMeaningful(newViewProps.selectionColor)) {

ios/styles/LinkStyle.mm

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -367,18 +367,8 @@ + (BOOL)matchesLinkRegexWithConfig:(NSString *)url
367367
return NO;
368368
}
369369
NSRange range = NSMakeRange(0, url.length);
370-
if (linkRegexConfig.isDefault) {
371-
return [[self fullRegex] numberOfMatchesInString:url
372-
options:0
373-
range:range] > 0 ||
374-
[[self wwwRegex] numberOfMatchesInString:url options:0
375-
range:range] > 0 ||
376-
[[self bareRegex] numberOfMatchesInString:url
377-
options:0
378-
range:range] > 0;
379-
}
380370
NSRegularExpression *userRegex = [config parsedLinkRegex];
381-
if (userRegex == nullptr) {
371+
if (linkRegexConfig.isDefault || userRegex == nullptr) {
382372
return [[self fullRegex] numberOfMatchesInString:url
383373
options:0
384374
range:range] > 0 ||

0 commit comments

Comments
 (0)