Problem
Files like jquery-1.4.3.min.js contain the the version and/or variant in their filename. Because the declaration in hook_libraries_info() is (should be) static, there is no way to tell Libraries API to load that file.

Files: 
CommentFileSizeAuthor
#6 964986-4-libraries-replace-filenames.patch6.36 KBtstoeckler
PASSED: [[SimpleTest]]: [MySQL] 130 pass(es).
[ View ]
#4 964986-4-libraries-replace-filenames.patch6.36 KBtstoeckler
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 964986-4-libraries-replace-filenames.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Comments

Well, the easy way out would be to define a @version and a @variant placeholder, which could be used in filenames, and which would be automatically replaced by Libraries API.

There's 2 reasons, that's not enough, though:
1. Where does it end? Can filenames differ depending on their location (local and external/hosted versions)? Can they contain a date (e.g. the day that version was released)? In the end we need something pluggable.
2. The above fails already when e.g. the version is 1.4.3, but the filename is example-1-4-3.js

I read the above and immediately thought:

  1. No problem; use a regular expression.
  2. Now you've got two problems.

But seriously, couldn't you allow a regex to convert the @version and @variant into a filename?

Status:Active» Needs review
StatusFileSize
new6.36 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 964986-4-libraries-replace-filenames.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Now that we have callbacks, this shouldn't be too hard.
This is related to the whole file traversing debate though, see #1224838: Fix the inconsistency between filenames as array keys and array values for example.
I didn't want to go into that here, so I just do
foreach($files as $filename => $options)

Version:7.x-1.x-dev» 7.x-2.x-dev

Wrong branch...

StatusFileSize
new6.36 KB
PASSED: [[SimpleTest]]: [MySQL] 130 pass(es).
[ View ]

Same patch.

+++ b/libraries.api.php
@@ -164,8 +164,16 @@
+ *       The following pre-load callbacks are available for all libraries:
+ *       - libaries_replace_filenames: Use this callback if your library files
+ *         have version- or variant-dependant filenames. The callback replaces
+ *         all occurences of '!version' in filenames with the detected library
+ *         version and all occurences of '!variant' with the variant.

Per docs, this callback is invoked after the library has been detected. However, to detect a library with version or variant identifiers in its filename in the first place, the filename info needs to be adjusted in the pre-detect callback already.

I'm not sure whether this additional callback and automated replacement makes sense. Do we have a concrete use-case for this?

This issue mentions jQuery, but for that, we invented the pre-detect callback already, I think.

Title:Support version- and variant-dependent filenames.Support version- and variant-dependent filenames

FYI: Interesting tidbit; the commit that introduced CDN support for jquery_update module:
http://drupalcode.org/project/jquery_update.git/blobdiff/8a3a09fe9cfd231...