Issue with ResourceDefinition.ResolveUrl() when having culture specific scripts (double dot)

Topics: Core, Troubleshooting
Jan 2, 2012 at 11:55 PM
Edited Jan 2, 2012 at 11:56 PM

I am using jquery.globalize in my custom module. My ResourceManifest looks like this:

public class ResourceManifest : IResourceManifestProvider
        private readonly IOrchardServices _orchardServices;

        public ResourceManifest(IOrchardServices orchardServices)
            _orchardServices = orchardServices;

        public void BuildManifests(ResourceManifestBuilder builder)
            var manifest = builder.Add();
            var currentCulture = _orchardServices.WorkContext.CurrentCulture;

            manifest.DefineScript("Globalize").SetBasePath(manifest.BasePath + "scripts/jquery.globalize/").SetUrl("globalize.js").SetDependencies("jQuery");
            manifest.DefineScript("GlobalizeCultures").SetBasePath(manifest.BasePath + "scripts/jquery.globalize/cultures/").SetUrl("globalize.culture.js").SetCultures(currentCulture).SetDependencies("Globalize", "jQuery");
            manifest.DefineScript("ShoppingCart").SetUrl("shoppingcart.js", "shoppingcart.min.js").SetDependencies("jQuery", "GlobalizeCultures");

 The site runs in the culture "en-US", so the expected resource url for "globalize.culture.js" is: "~/mymodule/scripts/globalize.culture.en-US.js".
However, the following string is returned when calling the ResolveUrl method: "~/mymodule/scripts/globalize.culture.en-US..js" (notice the double dot).
It seems to be a bug on the following line in ResourceDefinition.ResolveUrl:

url = Path.ChangeExtension(url, nearestCulture + "." + Path.GetExtension(url));

The call to Path.GetExtension(url) will already return  the ".", so appending another "." will cause a double dot: "..".
It looks like the bug can be fixed by replacing the line with:

url = Path.ChangeExtension(url, nearestCulture + Path.GetExtension(url));
Jan 2, 2012 at 11:57 PM

Please file a bug.

Jan 3, 2012 at 12:11 AM

Just filed the bug here:

Jan 3, 2012 at 12:33 AM