radix3 icon indicating copy to clipboard operation
radix3 copied to clipboard

feat: URL filtering with `createFilter`

Open harlan-zw opened this issue 3 years ago • 3 comments

Copied from https://github.com/unjs/ufo/pull/99


The createFilter is a popular util from Rollup to filter system paths when transforming modules. This PR introduces a port of that util, but for URL paths.

Why?

I'm working on a Nuxt module that allows end users to filter paths that it should run on (nuxt-delay-hydration v1). I need something that is straightforward to define inclusions and exclusions.

Generally, this function can be used wherever the end user needs to target a set of routes with certain exclusions.

How

The API is pretty much the same as the rollup createFilter, supporting whatever tokens Radix3 supports as well as regex.

I'm open to dropping regex support if you want to keep parity with the rest of the Radix3 API, let me know your thoughts.

Thanks!

harlan-zw avatar Nov 24 '22 10:11 harlan-zw

Codecov Report

Merging #30 (35cb728) into main (7dade62) will not change coverage. The diff coverage is 100.00%.

@@            Coverage Diff            @@
##              main       #30   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            4         5    +1     
  Lines          321       354   +33     
  Branches        61        76   +15     
=========================================
+ Hits           321       354   +33     
Impacted Files Coverage Δ
src/utils.ts 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov[bot] avatar Nov 24 '22 10:11 codecov[bot]

Hey @pi0

Any chance you could review this one?

I'm currently using it with 2 public modules and private repo and intend to keep using it where needed.

harlan-zw avatar Jan 24 '23 00:01 harlan-zw

Sorry for late review @harlan-zw.

Implementation seems quite good only I'm not sure about supporting regex matchers. A main promise of radix3 in design is that by keeping patterns simple (* / named / wildcard) they can have the maximum integration with platform native configurations (nginx, vercel, etc)

While i understand it could be useful for basic validation, perhaps we can support regex as a super-set layer out of this util and per projects?

pi0 avatar Jan 24 '23 11:01 pi0

Closing as this feature is not relevant to this library roadmap.

I think pathe/utils could be perhaps a better candidate.

pi0 avatar Jul 04 '24 18:07 pi0