Adding a function capable of extracting the name with version out of url/file path

This commit is contained in:
Michael Raskin 2012-09-13 13:59:23 +04:00
parent 14b1ed53a0
commit de5be50b2d

View File

@ -155,4 +155,14 @@ rec {
# Return true iff string v1 denotes a version older than v2.
versionOlder = v1: v2: builtins.compareVersions v2 v1 == 1;
# Extract name with version from URL. Ask for separator which is
# supposed to start extension
nameFromURL = url: sep: let
components = splitString "/" url;
filename = lib.last components;
name = builtins.head (splitString sep filename);
in
assert ! eqStrings name filename;
name;
}