Tuesday 25 August 2015

Spring: Difference of /** and /* with regards to paths

Three basic rules for URL regex:
  1. ? matches one character.
  2. * matches zero or more characters.
  3. ** matches zero or more 'directories' in a path.

An asterisk ('*') matches zero or more characters, up to the occurrence of a '/' character (which serves as a path separator).
A string, such as "/abcd/docs/index.html", would not match successfully against the pattern '/*/*.index.html'. The first asterisk matches up to the first path separator only, resulting in the "abcd" string. A successful matching pattern would be '/*/*/*.html'.

A string containing two asterisks ('**') matches zero or more characters.
This could include the path separator '/'. In this case, "/abcd/docs/index.html" would successfully match the '/**/*.html' pattern. The double asterisk, including the path separator, would match the "abcd/docs" string.

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...