praeclarum / FuGetGallery

An alternative web UI for browsing nuget packages

Home Page:https://www.fuget.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Frameworks links don't work on the main page of a package

svick opened this issue · comments

When you go to e.g. https://www.fuget.org/packages/Microsoft.Bcl.AsyncInterfaces/1.0.0, all the Frameworks links (i.e. net461 and netstandard2.0) don't do anything: they link back to the same page.

If you go to a subpage for the package (e.g. https://www.fuget.org/packages/Microsoft.Bcl.AsyncInterfaces/1.0.0/lib/netstandard2.1/Microsoft.Bcl.AsyncInterfaces.dll), then the links start to work.

The bug is in this method:

string GetUrl(object oid = null, object oversion = null, object otargetFramework = null, object odir = null, object oassemblyName = null, object onamespace = null, object otypeName = null, object ocode = null) {
oid = (oid ?? package?.Id) ?? RouteData.Values["id"];
oversion = (oversion ?? package?.Version) ?? RouteData.Values["version"];
otargetFramework = (otargetFramework ?? framework?.Moniker) ?? RouteData.Values["targetFramework"];
odir = (odir ?? dir) ?? RouteData.Values["dir"];
if (autodir && oassemblyName == null && onamespace == null && otypeName == null && ocode == null)
odir = null;
oassemblyName = (oassemblyName ?? asm?.FileName) ?? ("diff".Equals(RouteData.Values["assemblyName"]) ? null : RouteData.Values["assemblyName"]);
onamespace = (onamespace ?? ns?.Key) ?? RouteData.Values["namespace"];
otypeName = otypeName ?? RouteData.Values["typeName"];
ocode = ocode ?? Request.Query["code"].FirstOrDefault();
var r = "/packages";
if (oid != null) {
r += "/" + Uri.EscapeDataString(oid.ToString());
if (oversion != null) {
r += "/" + Uri.EscapeDataString(oversion.ToString());
if (odir != null) {
r += "/" + Uri.EscapeDataString(odir.ToString());
if (otargetFramework != null) {
r += "/" + Uri.EscapeDataString(otargetFramework.ToString());
if (oassemblyName != null) {
r += "/" + Uri.EscapeDataString(oassemblyName.ToString());
if (onamespace != null) {
r += "/" + Uri.EscapeDataString(onamespace.ToString());
if (otypeName != null) {
r += "/" + Uri.EscapeDataString(otypeName.ToString());
}
}
}
}
}
}
}
if ("true".Equals(ocode) && package.AllowedToDecompile) {
r += "?code=true";
}
return r;
}

I tried to give it a go but there is a lot going on and the method already contains a bodge to fix another, similar, issue (lines 118-119) and there is no tests so IMHO the way forward would be to rewrite that method but that is not a simple task. Give it a go if you like ;)