Skip to content

feat: support withoutQuery utility - #390

Open
abhi-byte62 wants to merge 1 commit into
unjs:mainfrom
abhi-byte62:feat/without-query
Open

abhi-byte62 wants to merge 1 commit into
unjs:mainfrom
abhi-byte62:feat/without-query

Conversation

@abhi-byte62

@abhi-byte62 abhi-byte62 commented Oct 7, 2026 •

Copy link
Copy Markdown

Resolves #297

Description

Adds a dedicated withoutQuery(input: string): string utility function to strip the entire query string from a URL while preserving the pathname, host, protocol, and hash/fragment.

Example

withoutQuery("/foo?bar=1&baz=2") // "/foo"
withoutQuery("http://example.com/foo?q=123#bar") // "http://example.com/foo#bar"

Summary by CodeRabbit

  • New Features

    • Added a utility to remove query parameters from a URL while preserving its path, origin, and fragment.
  • Tests

    • Added coverage for empty inputs and URLs with different paths, queries, and fragments.

@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: be71d0f3-101f-4cc8-8cb1-02819da2cbef
📥 Commits

Reviewing files that changed from the base of the PR and between f06c800 and eda1a5f.

📒 Files selected for processing (3)
  • src/utils.ts
  • test/query.test.ts
  • test/utilities.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The change adds the exported withoutQuery(input: string): string utility. It removes the URL query section and includes tests for retaining paths, origins, and fragments.

Changes

Query Removal

Layer / File(s) Summary
Add and test withoutQuery
src/utils.ts, test/query.test.ts, test/utilities.test.ts
Adds withoutQuery, which clears the parsed URL search component and serializes the result. Tests cover empty inputs, paths, origins, query strings, and fragments.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Feature

Merge Risk: ⚪ Minimal · up to eda1a

The utility removes the query while preserving the covered URL components. No actionable merge-blocking issue is established.

Architecture Summary

Architecture risk: 🔵 Low · up to eda1a

The change affects 2 systems.

Changed systems: src, test

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — src (service) was modified; 1 changed file maps to changed impact.
  • observed — test (service) was modified; 2 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in src/utils.ts: Added withoutQuery, which parses the input URL, clears its search component, and serializes the result.
  • observed — Modified behavior in test/query.test.ts: The import now includes withoutQuery.
  • observed — Modified behavior in test/query.test.ts: Adds withoutQuery tests expecting query strings to be removed while retaining URL components outside the query, including fragments; also covers empty input and an empty query marker.
  • observed — Modified behavior in test/utilities.test.ts: The test file adds withoutQuery to its imports.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: adding support for the withoutQuery utility.
Linked Issues check ✅ Passed Issue #297 requires an exported withoutQuery(input: string): string utility that removes the query section. src/utils.ts adds the exported function, parses the input, clears search, and serializ…
Out of Scope Changes check ✅ Passed The changes add only the withoutQuery utility and focused automated tests for its query-removal and URL-preservation behavior. The changes support issue #297 and do not show unrelated implementation…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 3 files.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed due to a network error.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

Support withoutQuery

1 participant