about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/features/compose/containers/warning_container.js
diff options
context:
space:
mode:
authorkedama <kedama@foresdon.jp>2020-08-02 18:19:43 +0900
committerThibaut Girka <thib@sitedethib.com>2020-08-02 14:33:22 +0200
commit1d8e930445b1ef2cdef54d723b0efd4235253889 (patch)
tree09c6307d9af921ba61e0abd1ce7f026d6e7f6f14 /app/javascript/flavours/glitch/features/compose/containers/warning_container.js
parent23cd5f2c154e228b6b7257e4f079550ec532da1e (diff)
[Glitch] Fix the hashtag judgment of the compose form to be the same as the server side
Port cd94854e7d14b2bc755510493944a3e01f758fa2 to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
Diffstat (limited to 'app/javascript/flavours/glitch/features/compose/containers/warning_container.js')
-rw-r--r--app/javascript/flavours/glitch/features/compose/containers/warning_container.js17
1 files changed, 16 insertions, 1 deletions
diff --git a/app/javascript/flavours/glitch/features/compose/containers/warning_container.js b/app/javascript/flavours/glitch/features/compose/containers/warning_container.js
index b9b0a2644..ea970c61f 100644
--- a/app/javascript/flavours/glitch/features/compose/containers/warning_container.js
+++ b/app/javascript/flavours/glitch/features/compose/containers/warning_container.js
@@ -6,7 +6,22 @@ import { FormattedMessage } from 'react-intl';
 import { me } from 'flavours/glitch/util/initial_state';
 import { profileLink, termsLink } from 'flavours/glitch/util/backend_links';
 
-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']),