Skip to content

How should my app handle links that appear in generated text?

Render generated links only through a restricted link policy, and do not label them verified merely because a model produced them. Validate allowed URL schemes, control new-tab behavior and avoid automatic server fetching. AISwapLab's text endpoint does not browse or independently verify the destinations it mentions.

PROTECT API ACCESS AND RESULTSAISwapLab team · Editorial methodUpdated 2 min read
Open API documentationExplore 67 Image SkillsPrivate keys · Explicit credit approval
Article workflow: Parse before rendering; Control navigation behavior; Label verification accurately.
Workflow diagram: Parse before rendering → Control navigation behavior → Label verification accurately. Read the article for evidence and limits.

A clickable link implies more than text

A user may trust a polished answer's references even when the URLs are invented. A renderer also needs to prevent unsafe schemes and unwanted window relationships. Link safety and factual source verification are different checks and should be described separately.

What to do next

  1. 01

    Parse before rendering

    Use a URL parser and an allowlist of schemes appropriate to your product. Reject executable or unexpected schemes, and avoid turning arbitrary text into privileged internal application routes or backend fetch requests.

  2. 02

    Control navigation behavior

    For external links opened in a new tab, apply an appropriate opener policy and a deliberate referrer policy. Show the destination domain when useful, particularly when displayed link text differs from the actual target.

  3. 03

    Label verification accurately

    If your application has not retrieved and checked a source, present it as a model-suggested reference. Any verification feature should run through a separately reviewed fetch policy and record what was checked and when.

A concrete example

Illustrative example: a generated answer proposes a documentation URL. The UI permits its HTTPS link and shows the domain, but marks it Suggested source. A javascript-style link fixture is rejected rather than rendered as an actionable reference.

Before you call it ready

  • Unsafe schemes never become clickable.
  • External navigation has an opener policy.
  • Suggested and verified sources remain distinct.

A locally executed, reproducible check

Parsing a link does not establish a permitted scheme or an expected hostname.

We executed this exact synthetic fixture on November 16, 2026 with Python 3.12.10 and SQLite 3.49.1. It ran locally with no network requests, account data or model generation. The recorded output below is an observation from that environment, not a platform benchmark. Copy the code into a separate Python file to repeat it in a suitable local environment; compare the mechanism and check your runtime version.

python
from urllib.parse import urlsplit
for link in ('javascript:example()', 'https://aiswaplab.com@elsewhere.invalid/output', 'https://aiswaplab.com/guides'):
    parsed=urlsplit(link)
    print('scheme:',parsed.scheme,'host:',parsed.hostname,'has-userinfo:',parsed.username is not None)

Recorded output and interpretation

No link is opened or executed. The hostname after the at-sign is the relevant host in this example, not the text that resembles a familiar brand before it. Parsing is not authorization, ownership verification or protection against every Unicode/domain confusion.

A matching local output establishes only the illustrated library or database behavior under these inputs. It does not certify a production integration. Preserve the approved action, authorization boundaries and current AISwapLab request contract when applying the idea.

text
scheme: javascript host: None has-userinfo: False
scheme: https host: elsewhere.invalid has-userinfo: True
scheme: https host: aiswaplab.com has-userinfo: False

When to stop or choose another method

Stop treating model-generated citations as verified evidence or automatically fetching their destinations with privileged server credentials.

Sources

One task. A recoverable workflow.

Check the contract, approve the quote and retain the job.

Open API documentation