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(); $path = System::GetVirtualPath();
// strip path extension if there is one if (System::$Configuration["Runtime.DisableAutomaticExtensionParsing"] !== true)
$pathLast = $path[count($path) - 1];
$ix = strripos($pathLast, ".");
if ($ix !== false)
{ {
$pathExt = substr($pathLast, $ix + 1); // strip path extension if there is one
$path[count($path) - 1] = substr($pathLast, 0, $ix); $pathLast = $path[count($path) - 1];
$ix = strripos($pathLast, ".");
switch ($pathExt) if ($ix !== false)
{ {
case "json": $pathExt = substr($pathLast, $ix + 1);
$path[count($path) - 1] = substr($pathLast, 0, $ix);
switch ($pathExt)
{ {
System::$WebPageFormat = WebPageFormat::JSON; case "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::$WebPageFormat = WebPageFormat::JSON;
System::Redirect("~/" . implode("/", $path)); break;
return; }
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); $pathVarName = substr($pathPart, 2, strlen($pathPart) - 3);
$pathVars[$pathVarName] = $actualPathParts[$i]; $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 else
{ {
$app = ""; $app = "";