Skip to content

Update URL validation logic in LinkEditForm - #4389

Draft
ilBiondojs wants to merge 3 commits into
umami-software:devfrom
ilBiondojs:patch-1
Draft

ilBiondojs wants to merge 3 commits into
umami-software:devfrom
ilBiondojs:patch-1

Conversation

@ilBiondojs

@ilBiondojs ilBiondojs commented Jul 15, 2026

Copy link
Copy Markdown

This is a fairly superficial fix. It prevents using the same forwarding URL as the primary link, but realistically it’s an unlikely scenario since no one would normally set identical values for both.


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

@vercel

vercel Bot commented Jul 15, 2026

Copy link
Copy Markdown

@ilBiondojs is attempting to deploy a commit to the Umami Software Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps

greptile-apps Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a validation check in LinkEditForm to prevent the forwarding URL from matching the link's own generated URL (${hostUrl}/${slug}).

  • The change introduces a syntax error — an extra closing ) on line 63 breaks the TypeScript parse step, so the app will not compile at all.
  • Even if the syntax were fixed, slug is declared inside the Form render-prop callback (line 80) and is therefore undefined at the outer checkUrl scope, meaning the guard would evaluate against ${hostUrl}/undefined and never match a real user input.

Confidence Score: 1/5

Not safe to merge — the change introduces a compile-time syntax error that would break the build.

The only modified file has two defects on the single changed line: a stray closing parenthesis that prevents TypeScript compilation, and a scoping mistake that would make the new validation guard a no-op even after the syntax is fixed. The PR cannot ship in its current state.

src/app/(main)/links/LinkEditForm.tsx — the checkUrl function needs both the syntax fix and to be moved inside the render-prop callback where slug is available.

Important Files Changed

Filename Overview
src/app/(main)/links/LinkEditForm.tsx Adds a check to prevent using the link's own URL as the forwarding destination, but introduces a compile-time syntax error (extra )) and a scoping bug where slug is undefined at the point checkUrl runs, making the new guard inoperative.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User submits form] --> B[checkUrl called with url]
    B --> C{isValidUrl url}
    C -- No --> D[Return invalidUrl error]
    C -- Yes --> E{url equals hostUrl/slug}
    E -- Yes --> D
    E -- No --> F[Return true - valid]
    G[slug defined inside Form render-prop] -. slug is undefined at checkUrl scope .-> E
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[User submits form] --> B[checkUrl called with url]
    B --> C{isValidUrl url}
    C -- No --> D[Return invalidUrl error]
    C -- Yes --> E{url equals hostUrl/slug}
    E -- Yes --> D
    E -- No --> F[Return true - valid]
    G[slug defined inside Form render-prop] -. slug is undefined at checkUrl scope .-> E
Loading

Comments Outside Diff (1)

  1. src/app/(main)/links/LinkEditForm.tsx, line 62-67 (link)

    P1 slug is out of scope in checkUrl

    slug is declared on line 80 inside the render-prop callback (({ setValue, watch }) => { const slug = watch('slug'); ... }), but checkUrl is defined at the component function scope above that callback. At runtime slug will be undefined, so the guard produces url === \${hostUrl}/undefined`— a string no user would ever type — meaning the new check silently never fires. The function needs to be defined inside the render-prop callback whereslugis in scope, or acceptslug` as a parameter and be called from there.

Reviews (1): Last reviewed commit: "Update URL validation logic in LinkEditF..." | Re-trigger Greptile

Comment thread src/app/(main)/links/LinkEditForm.tsx Outdated
@ilBiondojs

Copy link
Copy Markdown
Author

Not sure if I get the correct value by getting it from formValues in the validation query. I didn't right understand how to get the data of the form in the validation query

@ilBiondojs
ilBiondojs changed the base branch from master to dev July 23, 2026 11:18
@ilBiondojs
ilBiondojs marked this pull request as draft July 23, 2026 11:19

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant