@particle-academy/fancy-connector-core 0.10.0 → 0.10.1

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/dist/index.d.cts CHANGED
@@ -1653,18 +1653,6 @@ declare function byteRangeOf(text: string, charIndex: number, substring: string)
1653
1653
  * exception three frames away.
1654
1654
  */
1655
1655
  declare function sliceByteRange(text: string, range: ByteRange): string;
1656
- /**
1657
- * Bare URLs in `text`, with their UTF-8 byte ranges.
1658
- *
1659
- * Trailing punctuation is excluded: a link at the end of a sentence would
1660
- * otherwise swallow the full stop and 404. Closing brackets go too, for the same
1661
- * reason and because a URL in parentheses is common in prose.
1662
- *
1663
- * This is the generic half of a "link facet" — a connector maps the ranges into
1664
- * whatever its provider's rich-text shape is. The package owns the offsets
1665
- * because the offsets are what people get wrong; it does not own the provider's
1666
- * schema, because that is the provider's.
1667
- */
1668
1656
  declare function linkRanges(text: string): Array<ByteRange & {
1669
1657
  url: string;
1670
1658
  }>;
package/dist/index.d.ts CHANGED
@@ -1653,18 +1653,6 @@ declare function byteRangeOf(text: string, charIndex: number, substring: string)
1653
1653
  * exception three frames away.
1654
1654
  */
1655
1655
  declare function sliceByteRange(text: string, range: ByteRange): string;
1656
- /**
1657
- * Bare URLs in `text`, with their UTF-8 byte ranges.
1658
- *
1659
- * Trailing punctuation is excluded: a link at the end of a sentence would
1660
- * otherwise swallow the full stop and 404. Closing brackets go too, for the same
1661
- * reason and because a URL in parentheses is common in prose.
1662
- *
1663
- * This is the generic half of a "link facet" — a connector maps the ranges into
1664
- * whatever its provider's rich-text shape is. The package owns the offsets
1665
- * because the offsets are what people get wrong; it does not own the provider's
1666
- * schema, because that is the provider's.
1667
- */
1668
1656
  declare function linkRanges(text: string): Array<ByteRange & {
1669
1657
  url: string;
1670
1658
  }>;
package/dist/index.js CHANGED
@@ -1743,11 +1743,17 @@ function sliceByteRange(text, range) {
1743
1743
  const bytes = encoder.encode(text);
1744
1744
  return new TextDecoder().decode(bytes.slice(range.byteStart, range.byteEnd));
1745
1745
  }
1746
+ var TRAILING_PUNCTUATION = /* @__PURE__ */ new Set([".", ",", ";", ":", "!", "?", ")", "]", "}", "'", '"']);
1747
+ function trimTrailingPunctuation(raw) {
1748
+ let end = raw.length;
1749
+ while (end > 0 && TRAILING_PUNCTUATION.has(raw[end - 1])) end -= 1;
1750
+ return raw.slice(0, end);
1751
+ }
1746
1752
  function linkRanges(text) {
1747
1753
  const found = [];
1748
1754
  for (const match of text.matchAll(/https?:\/\/[^\s]+/g)) {
1749
1755
  if (match.index === void 0) continue;
1750
- const url = match[0].replace(/[.,;:!?)\]}'"]+$/, "");
1756
+ const url = trimTrailingPunctuation(match[0]);
1751
1757
  found.push({ ...byteRangeOf(text, match.index, url), url });
1752
1758
  }
1753
1759
  return found;