Web Optimization {version} pattern in bundles

While creating a website using Web Optimization to handle bundling, I became curious as to what the {version} pattern matched. I couldn't find documentation for this besides what it outlined here:

The bundling framework follows several common conventions such as:
•Selecting “.min” file for release when “FileX.min.js” and “FileX.js” exist. 
•Selecting the non “.min” version for debug.
•Ignoring “-vsdoc” files (such as jquery-1.7.1-vsdoc.js), which are used only by IntelliSense. 

Digging into the source code here, I was able to find exactly what {version} matches, the C# regex @"(\d+(\s*\.\s*\d+){1,3})(-[a-z][0-9a-z-]*)?". This means it matches:
1 or more digits followed by
   0 or more whitespace followed by
   the '.' character followed by
   0 or more whitespace followed by
   1 or more digits followed by
the preceding group at least 1 times but no more than 3 times optionally followed  by
   the '-' character followed by
   any a-z character followed by
   0 or more a-z characters or numbers
Example matches would be:
  • 1.23.23-a9
  • 1.23.23
  • 2.34
  • 2.2-min
  • 2
I hope that helps clears things up for some people.
Post a Comment