james-proxy / james

Web Debugging Proxy Application
1.42k stars 126 forks source link

Allow double-wildcards, partial-wildcards #69

Open mitchhentges opened 8 years ago

mitchhentges commented 8 years ago

As of the url-wildcard branch, wildcards can fill in between any two /. This behaviour should be extended to allow partial wildcards (http://foo.com/bar*/*.css) and double-wildcards (e.g. http://foo.com/**/*.css)

Specification

  1. When there's a single * between two /, match any content, so long as it's between the same /
  2. When there's a double-wildcard, allow any content and any number of /, so long as the other parts of the url-mapping "mask" are met
  3. If there's * with other characters between two /, then match the characters, with anything being allowed in place of the wildcard(s)

Things to make this feature not overly complex (>Implying that it's not already too complex, lol sorry)

  1. If there's more than one double-wildcard, the url-mapping mask is invalid. It'd be too much of a slipperly slope to allow that.
  2. Between two /, there can be a maximum of two separate *. This is to stop situations like: http://foo.com/*cats*bagels*spaghetti_lol*

Examples:

-> mask: http://foo.com/*/style.css
http://foo.com/a.css //not mapped
http://foo.com/bar/style.css //is mapped, see #1
http://foo.com/bar/a/style.css //is not mapped, see #1 (The `/a/` component isn't in the mask)

-> mask: http://foo.com/**/style.css
http://foo.com/a.css //not mapped
http://foo.com/bar/style.css //is mapped, see #2 (any content between `http://foo.com/` and `/style.css` is allowed)
http://foo.com/bar/a/style.css //is mapped, see #2

-> mask: http://foo.com/bar*/*.css
http://foo.com/a.css //not mapped
http://foo.com/bar/style.css //is mapped
http://foo.com/bar/neat.css //is mapped
http://foo.com/bars-and-chipz/neat.css //is mapped
http://foo.com/blitz-bars-and-chipz/neat.css //is not mapped
http://foo.com/bar/a/style.css //is not mapped

-> mask: http://foo.com/**/bar/** //error, can't have multiple **
-> mask: http://foo.com/*bar*baz*/style.css //error, can't have over two * per between two /
mitchhentges commented 8 years ago

What if we just used route-pattern?