[PR #1206] [MERGED] fix: use native URL parser instead of wrong regex #1472

Closed
opened 2026-02-26 19:33:24 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/documenso/documenso/pull/1206
Author: @aeris
Created: 6/29/2024
Status: Merged
Merged: 7/31/2024
Merged by: @Mythie

Base: mainHead: parse-url


📝 Commits (3)

  • a5d57f9 fix: use native URL parser instead of wrong regex
  • 1b260be Merge branch 'main' into parse-url
  • 99d5966 chore: minor updates

📊 Changes

7 files changed (+38 additions, -19 deletions)

View changed files

packages/lib/constants/url-regex.ts (+0 -2)
📝 packages/lib/schemas/common.ts (+3 -3)
packages/lib/utils/is-valid-redirect-url.ts (+16 -0)
📝 packages/trpc/server/document-router/schema.ts (+7 -5)
📝 packages/trpc/server/template-router/schema.ts (+4 -3)
📝 packages/ui/primitives/document-flow/add-settings.types.ts (+4 -3)
📝 packages/ui/primitives/template-flow/add-template-settings.types.tsx (+4 -3)

📄 Description

Current way to validate URL from regex is bugged

  • no support for auth part URL_REGEX.test("http://auth@example.org")
  • no support for explicit port URL_REGEX.test("http://example.org:5000")
  • no support for fragment URL_REGEX.test("http://example.org#foo")
  • no support for query URL_REGEX.test("http://example.org?foo=bar")
  • valid domain rejection URL_REGEX.test("http://localhost")

This patch use the native URL node parsing to test correctly for URL validity

Summary by CodeRabbit

  • Refactor
    • Improved URL validation by changing the method from a regular expression pattern to a function that tests the validity of a URL. This should enhance accuracy in URL validation.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/documenso/documenso/pull/1206 **Author:** [@aeris](https://github.com/aeris) **Created:** 6/29/2024 **Status:** ✅ Merged **Merged:** 7/31/2024 **Merged by:** [@Mythie](https://github.com/Mythie) **Base:** `main` ← **Head:** `parse-url` --- ### 📝 Commits (3) - [`a5d57f9`](https://github.com/documenso/documenso/commit/a5d57f99047405634d83b45ab95279a73954fc89) fix: use native URL parser instead of wrong regex - [`1b260be`](https://github.com/documenso/documenso/commit/1b260be6b91194f5b9155a3cfa2c3df4dee3d40f) Merge branch 'main' into parse-url - [`99d5966`](https://github.com/documenso/documenso/commit/99d5966d718b8958ee639231a41cb32c404905e8) chore: minor updates ### 📊 Changes **7 files changed** (+38 additions, -19 deletions) <details> <summary>View changed files</summary> ➖ `packages/lib/constants/url-regex.ts` (+0 -2) 📝 `packages/lib/schemas/common.ts` (+3 -3) ➕ `packages/lib/utils/is-valid-redirect-url.ts` (+16 -0) 📝 `packages/trpc/server/document-router/schema.ts` (+7 -5) 📝 `packages/trpc/server/template-router/schema.ts` (+4 -3) 📝 `packages/ui/primitives/document-flow/add-settings.types.ts` (+4 -3) 📝 `packages/ui/primitives/template-flow/add-template-settings.types.tsx` (+4 -3) </details> ### 📄 Description Current way to validate URL from regex is bugged - no support for auth part `URL_REGEX.test("http://auth@example.org")` - no support for explicit port `URL_REGEX.test("http://example.org:5000")` - no support for fragment `URL_REGEX.test("http://example.org#foo")` - no support for query `URL_REGEX.test("http://example.org?foo=bar")` - valid domain rejection `URL_REGEX.test("http://localhost")` This patch use the native URL node parsing to test correctly for URL validity <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Improved URL validation by changing the method from a regular expression pattern to a function that tests the validity of a URL. This should enhance accuracy in URL validation. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-26 19:33:24 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/documenso#1472
No description provided.