diff --git a/source/dub/packagesuppliers/filesystem.d b/source/dub/packagesuppliers/filesystem.d index e271510..9cfb55e 100644 --- a/source/dub/packagesuppliers/filesystem.d +++ b/source/dub/packagesuppliers/filesystem.d @@ -52,6 +52,7 @@ { import std.array : split; import std.path : stripExtension; + import std.algorithm : startsWith, endsWith; import dub.internal.utils : packageInfoFileFromZip; import dub.recipe.io : parsePackageRecipe; import dub.recipe.json : toJson; @@ -61,7 +62,10 @@ string packageFileContent = packageInfoFileFromZip(filePath, packageFileName); auto recipe = parsePackageRecipe(packageFileContent, packageFileName); Json json = toJson(recipe); - json["version"] = filePath.toNativeString().split("-")[$-1].stripExtension(); + auto basename = filePath.head.name; + enforce(basename.endsWith(".zip"), "Malformed package filename: " ~ filePath.toNativeString); + enforce(basename.startsWith(packageId), "Malformed package filename: " ~ filePath.toNativeString); + json["version"] = basename[packageId.length + 1 .. $-4]; return json; } diff --git a/test/filesystem-version-with-buildinfo.sh b/test/filesystem-version-with-buildinfo.sh new file mode 100755 index 0000000..a9e24b1 --- /dev/null +++ b/test/filesystem-version-with-buildinfo.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +DIR=$(dirname "${BASH_SOURCE[0]}") + +. "$DIR"/common.sh + +${DUB} remove fs-json-dubpackage --non-interactive 2>/dev/null || true + +echo "Trying to get fs-json-dubpackage (1.0.7)" +${DUB} fetch fs-json-dubpackage@1.0.7 --skip-registry=all --registry=file://"$DIR"/filesystem-version-with-buildinfo + +if ! ${DUB} remove fs-json-dubpackage@1.0.7 2>/dev/null; then + die $LINENO 'DUB did not install package from file system.' +fi diff --git a/test/filesystem-version-with-buildinfo/.no_build b/test/filesystem-version-with-buildinfo/.no_build new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/filesystem-version-with-buildinfo/.no_build diff --git a/test/filesystem-version-with-buildinfo/fs-json-dubpackage-1.0.7+build-9-9-9.zip b/test/filesystem-version-with-buildinfo/fs-json-dubpackage-1.0.7+build-9-9-9.zip new file mode 100644 index 0000000..1b9915e --- /dev/null +++ b/test/filesystem-version-with-buildinfo/fs-json-dubpackage-1.0.7+build-9-9-9.zip Binary files differ