]> cat aescling's git repositories - mastodon.git/commitdiff
[Glitch] Fix the hashtag judgment of the compose form to be the same as the server...
authorkedama <kedama@foresdon.jp>
Sun, 2 Aug 2020 09:19:43 +0000 (18:19 +0900)
committerThibaut Girka <thib@sitedethib.com>
Sun, 2 Aug 2020 12:33:22 +0000 (14:33 +0200)
Port cd94854e7d14b2bc755510493944a3e01f758fa2 to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
app/javascript/flavours/glitch/features/compose/containers/warning_container.js

index b9b0a2644ec2301c828a9ece41d6ee578b6147c5..ea970c61f497a892d725f3efdbe1c45dd7805742 100644 (file)
@@ -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']),