add option to disable extension parsing and new shorter variable syntax

This commit is contained in:
Michael Becker 2023-11-01 23:23:17 -04:00
parent 6c87446672
commit 72a9b8d208

View File

@ -711,43 +711,46 @@
}
$path = System::GetVirtualPath();
// strip path extension if there is one
$pathLast = $path[count($path) - 1];
$ix = strripos($pathLast, ".");
if ($ix !== false)
if (System::$Configuration["Runtime.DisableAutomaticExtensionParsing"] !== true)
{
$pathExt = substr($pathLast, $ix + 1);
$path[count($path) - 1] = substr($pathLast, 0, $ix);
switch ($pathExt)
// strip path extension if there is one
$pathLast = $path[count($path) - 1];
$ix = strripos($pathLast, ".");
if ($ix !== false)
{
case "json":
$pathExt = substr($pathLast, $ix + 1);
$path[count($path) - 1] = substr($pathLast, 0, $ix);
switch ($pathExt)
{
System::$WebPageFormat = WebPageFormat::JSON;
break;
}
case "xml":
{
System::$WebPageFormat = WebPageFormat::XML;
break;
}
case "html":
{
System::$WebPageFormat = WebPageFormat::HTML;
break;
}
case "js":
{
System::$WebPageFormat = WebPageFormat::JavaScript;
break;
}
default:
{
if ($path[count($path) - 1] != "")
case "json":
{
$path[count($path) - 1] = $path[count($path) - 1];
System::Redirect("~/" . implode("/", $path));
return;
System::$WebPageFormat = WebPageFormat::JSON;
break;
}
case "xml":
{
System::$WebPageFormat = WebPageFormat::XML;
break;
}
case "html":
{
System::$WebPageFormat = WebPageFormat::HTML;
break;
}
case "js":
{
System::$WebPageFormat = WebPageFormat::JavaScript;
break;
}
default:
{
if ($path[count($path) - 1] != "")
{
$path[count($path) - 1] = $path[count($path) - 1];
System::Redirect("~/" . implode("/", $path));
return;
}
}
}
}
@ -778,6 +781,11 @@
$pathVarName = substr($pathPart, 2, strlen($pathPart) - 3);
$pathVars[$pathVarName] = $actualPathParts[$i];
}
else if (stripos($pathPart, "{") == 0 && stripos($pathPart, "}") == strlen($pathPart) - 1)
{
$pathVarName = substr($pathPart, 1, strlen($pathPart) - 2);
$pathVars[$pathVarName] = $actualPathParts[$i];
}
else
{
$app = "";