@pollinations/ui 0.1.0-alpha.4 → 0.1.0-alpha.6

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.cjs CHANGED
@@ -4345,10 +4345,21 @@ function linkedValue(value) {
4345
4345
  const formatted = formattedValue(value);
4346
4346
  const segments = formatted.split(/(https:\/\/[^\s"\\]+)/g);
4347
4347
  let offset = 0;
4348
- return segments.map((segment) => {
4348
+ return segments.map((segment, index) => {
4349
4349
  const key = `${offset}:${segment}`;
4350
4350
  offset += segment.length;
4351
- return segment.startsWith("https://") ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(InlineLink, { href: segment, children: segment }, key) : segment;
4351
+ if (!segment.startsWith("https://")) return segment;
4352
+ let href = segment;
4353
+ const quotedUrl = segments[index - 1]?.endsWith('"') && segments[index + 1]?.startsWith('"');
4354
+ let extraClosingParens = (href.match(/\)/g)?.length ?? 0) - (href.match(/\(/g)?.length ?? 0);
4355
+ while (!quotedUrl && (/[.,!?;:]$/.test(href) || href.endsWith(")") && extraClosingParens > 0)) {
4356
+ if (href.endsWith(")")) extraClosingParens--;
4357
+ href = href.slice(0, -1);
4358
+ }
4359
+ return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_react16.Fragment, { children: [
4360
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(InlineLink, { href, children: href }),
4361
+ segment.slice(href.length)
4362
+ ] }, key);
4352
4363
  });
4353
4364
  }
4354
4365
  function ToolValue({