@atproto/api 0.10.3 → 0.10.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @atproto/api
2
2
 
3
+ ## 0.10.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2260](https://github.com/bluesky-social/atproto/pull/2260) [`6ec885992`](https://github.com/bluesky-social/atproto/commit/6ec8859929a16f9725319cc398b716acf913b01f) Thanks [@estrattonbailey](https://github.com/estrattonbailey)! - Export regex from rich text detection
8
+
9
+ - [#2260](https://github.com/bluesky-social/atproto/pull/2260) [`6ec885992`](https://github.com/bluesky-social/atproto/commit/6ec8859929a16f9725319cc398b716acf913b01f) Thanks [@estrattonbailey](https://github.com/estrattonbailey)! - Disallow rare unicode whitespace characters from tags
10
+
11
+ - [#2260](https://github.com/bluesky-social/atproto/pull/2260) [`6ec885992`](https://github.com/bluesky-social/atproto/commit/6ec8859929a16f9725319cc398b716acf913b01f) Thanks [@estrattonbailey](https://github.com/estrattonbailey)! - Allow tags to lead with numbers
12
+
3
13
  ## 0.10.3
4
14
 
5
15
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@ export * from './agent';
8
8
  export * from './rich-text/rich-text';
9
9
  export * from './rich-text/sanitization';
10
10
  export * from './rich-text/unicode';
11
+ export * from './rich-text/util';
11
12
  export * from './moderation';
12
13
  export * from './moderation/types';
13
14
  export { LABELS } from './moderation/const/labels';
package/dist/index.js CHANGED
@@ -9059,13 +9059,17 @@ __export(src_exports2, {
9059
9059
  ListRecord: () => ListRecord,
9060
9060
  ListblockRecord: () => ListblockRecord,
9061
9061
  ListitemRecord: () => ListitemRecord,
9062
+ MENTION_REGEX: () => MENTION_REGEX,
9062
9063
  ModerationDecision: () => ModerationDecision,
9063
9064
  PostRecord: () => PostRecord,
9064
9065
  ProfileRecord: () => ProfileRecord,
9065
9066
  RepostRecord: () => RepostRecord,
9066
9067
  RichText: () => RichText,
9067
9068
  RichTextSegment: () => RichTextSegment,
9069
+ TAG_REGEX: () => TAG_REGEX,
9070
+ TRAILING_PUNCTUATION_REGEX: () => TRAILING_PUNCTUATION_REGEX,
9068
9071
  ThreadgateRecord: () => ThreadgateRecord,
9072
+ URL_REGEX: () => URL_REGEX,
9069
9073
  UnicodeString: () => UnicodeString,
9070
9074
  default: () => AtpAgent,
9071
9075
  jsonStringToLex: () => jsonStringToLex,
@@ -30137,12 +30141,18 @@ var tlds_default = [
30137
30141
  "\uD55C\uAD6D"
30138
30142
  ];
30139
30143
 
30144
+ // src/rich-text/util.ts
30145
+ var MENTION_REGEX = /(^|\s|\()(@)([a-zA-Z0-9.-]+)(\b)/g;
30146
+ var URL_REGEX = /(^|\s|\()((https?:\/\/[\S]+)|((?<domain>[a-z][a-z0-9]*(\.[a-z0-9]+)+)[\S]*))/gim;
30147
+ var TRAILING_PUNCTUATION_REGEX = /\p{P}+$/gu;
30148
+ var TAG_REGEX = /(^|\s)[##]((?!\ufe0f)[^\s\u00AD\u2060\u200A\u200B\u200C\u200D\u20e2]*[^\d\s\p{P}\u00AD\u2060\u200A\u200B\u200C\u200D\u20e2]+[^\s\u00AD\u2060\u200A\u200B\u200C\u200D\u20e2]*)?/gu;
30149
+
30140
30150
  // src/rich-text/detection.ts
30141
30151
  function detectFacets(text) {
30142
30152
  let match;
30143
30153
  const facets = [];
30144
30154
  {
30145
- const re = /(^|\s|\()(@)([a-zA-Z0-9.-]+)(\b)/g;
30155
+ const re = MENTION_REGEX;
30146
30156
  while (match = re.exec(text.utf16)) {
30147
30157
  if (!isValidDomain(match[3]) && !match[3].endsWith(".test")) {
30148
30158
  continue;
@@ -30164,7 +30174,7 @@ function detectFacets(text) {
30164
30174
  }
30165
30175
  }
30166
30176
  {
30167
- const re = /(^|\s|\()((https?:\/\/[\S]+)|((?<domain>[a-z][a-z0-9]*(\.[a-z0-9]+)+)[\S]*))/gim;
30177
+ const re = URL_REGEX;
30168
30178
  while (match = re.exec(text.utf16)) {
30169
30179
  let uri2 = match[2];
30170
30180
  if (!uri2.startsWith("http")) {
@@ -30199,10 +30209,12 @@ function detectFacets(text) {
30199
30209
  }
30200
30210
  }
30201
30211
  {
30202
- const re = /(^|\s)#((?!\ufe0f)[^\d\s]\S*)(?=\s)?/g;
30212
+ const re = TAG_REGEX;
30203
30213
  while (match = re.exec(text.utf16)) {
30204
30214
  let [, leading, tag] = match;
30205
- tag = tag.trim().replace(/\p{P}+$/gu, "");
30215
+ if (!tag)
30216
+ continue;
30217
+ tag = tag.trim().replace(TRAILING_PUNCTUATION_REGEX, "");
30206
30218
  if (tag.length === 0 || tag.length > 64)
30207
30219
  continue;
30208
30220
  const index = match.index + leading.length;