about summary refs log tree commit diff
path: root/app/javascript
diff options
context:
space:
mode:
authorkedama <kedama@foresdon.jp>2020-08-02 18:19:43 +0900
committerGitHub <noreply@github.com>2020-08-02 11:19:43 +0200
commitcd94854e7d14b2bc755510493944a3e01f758fa2 (patch)
treeca031a937b05fd0271d136ef60943481a3dc7436 /app/javascript
parentbfd5aea20686559f030ca0f2538bebc1943b398b (diff)
Fix the hashtag judgment of the compose form to be the same as the server side (#14484)
Diffstat (limited to 'app/javascript')
-rw-r--r--app/javascript/mastodon/features/compose/containers/warning_container.js17
1 files changed, 16 insertions, 1 deletions
diff --git a/app/javascript/mastodon/features/compose/containers/warning_container.js b/app/javascript/mastodon/features/compose/containers/warning_container.js
index 8200a319f..947d20c5a 100644
--- a/app/javascript/mastodon/features/compose/containers/warning_container.js
+++ b/app/javascript/mastodon/features/compose/containers/warning_container.js
@@ -5,7 +5,22 @@ import PropTypes from 'prop-types';
 import { FormattedMessage } from 'react-intl';
 import { me } from '../../../initial_state';
 
-const APPROX_HASHTAG_RE = /(?:^|[^\/\)\w])#(\w*[a-zA-Z·]\w*)/i;
+const HASHTAG_SEPARATORS = "_\\u00b7\\u200c";
+const ALPHA = '\\p{L}\\p{M}';
+const WORD = '\\p{L}\\p{M}\\p{N}\\p{Pc}';
+const APPROX_HASHTAG_RE = new RegExp(
+  '(?:^|[^\\/\\)\\w])#((' +
+  '[' + WORD + '_]' +
+  '[' + WORD + HASHTAG_SEPARATORS + ']*' +
+  '[' + ALPHA + HASHTAG_SEPARATORS + ']' +
+  '[' + WORD + HASHTAG_SEPARATORS +']*' +
+  '[' + WORD + '_]' +
+  ')|(' +
+  '[' + WORD + '_]*' +
+  '[' + ALPHA + ']' +
+  '[' + WORD + '_]*' +
+  '))', 'iu'
+);
 
 const mapStateToProps = state => ({
   needsLockWarning: state.getIn(['compose', 'privacy']) === 'private' && !state.getIn(['accounts', me, 'locked']),