create-prisma-php-app 2.0.0-beta.12 → 2.0.0-beta.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -64,6 +64,7 @@ final class Bootstrap
64
64
 
65
65
  Request::$pathname = $contentInfo['pathname'] ? '/' . $contentInfo['pathname'] : '/';
66
66
  Request::$uri = $contentInfo['uri'] ? $contentInfo['uri'] : '/';
67
+ Request::$decodedUri = Request::getDecodedUrl(Request::$uri);
67
68
 
68
69
  if (is_file(self::$contentToInclude)) {
69
70
  Request::$fileToInclude = basename(self::$contentToInclude);
@@ -674,7 +675,7 @@ final class Bootstrap
674
675
  }
675
676
  }
676
677
 
677
- $currentUrl = urldecode(Request::$uri);
678
+ $currentUrl = Request::getDecodedUrl(Request::$uri);
678
679
 
679
680
  if (isset($currentData[$currentUrl])) {
680
681
  $currentData[$currentUrl]['includedFiles'] = array_values(array_unique(
@@ -686,7 +687,7 @@ final class Bootstrap
686
687
  }
687
688
  } else {
688
689
  $currentData[$currentUrl] = [
689
- 'url' => $currentUrl,
690
+ 'url' => Request::$uri,
690
691
  'fileName' => self::convertUrlToFileName($currentUrl),
691
692
  'isCacheable' => CacheHandler::$isCacheable,
692
693
  'cacheTtl' => CacheHandler::$ttl,
@@ -706,7 +707,7 @@ final class Bootstrap
706
707
  {
707
708
  $url = trim($url, '/');
708
709
  $fileName = preg_replace('/[^a-zA-Z0-9-_]/', '_', $url);
709
- return $fileName ?: 'index';
710
+ return $fileName ? mb_strtolower($fileName, 'UTF-8') : 'index';
710
711
  }
711
712
 
712
713
  private static function authenticateUserToken(): void
@@ -818,16 +819,16 @@ try {
818
819
  }
819
820
 
820
821
  // If there’s caching
821
- if (isset(Bootstrap::$requestFilesData[Request::$uri])) {
822
+ if (isset(Bootstrap::$requestFilesData[Request::$decodedUri])) {
822
823
  if ($_ENV['CACHE_ENABLED'] === 'true') {
823
- CacheHandler::serveCache(Request::$uri, intval($_ENV['CACHE_TTL']));
824
+ CacheHandler::serveCache(Request::$decodedUri, intval($_ENV['CACHE_TTL']));
824
825
  }
825
826
  }
826
827
 
827
828
  // For wire calls, re-include the files if needed
828
829
  if (Request::$isWire && !Bootstrap::$secondRequestC69CD) {
829
- if (isset(Bootstrap::$requestFilesData[Request::$uri])) {
830
- foreach (Bootstrap::$requestFilesData[Request::$uri]['includedFiles'] as $file) {
830
+ if (isset(Bootstrap::$requestFilesData[Request::$decodedUri])) {
831
+ foreach (Bootstrap::$requestFilesData[Request::$decodedUri]['includedFiles'] as $file) {
831
832
  if (file_exists($file)) {
832
833
  ob_start();
833
834
  require_once $file;
@@ -852,8 +853,8 @@ try {
852
853
  MainLayout::$html = TemplateCompiler::injectDynamicContent(MainLayout::$html);
853
854
  MainLayout::$html = "<!DOCTYPE html>\n" . MainLayout::$html;
854
855
 
855
- if (isset(Bootstrap::$requestFilesData[Request::$uri]['fileName']) && $_ENV['CACHE_ENABLED'] === 'true') {
856
- CacheHandler::saveCache(Request::$uri, MainLayout::$html);
856
+ if (isset(Bootstrap::$requestFilesData[Request::$decodedUri]['fileName']) && $_ENV['CACHE_ENABLED'] === 'true') {
857
+ CacheHandler::saveCache(Request::$decodedUri, MainLayout::$html);
857
858
  }
858
859
 
859
860
  echo MainLayout::$html;
@@ -88,6 +88,11 @@ class Request
88
88
  */
89
89
  public static string $uri = '';
90
90
 
91
+ /**
92
+ * @var string $decodedUri Holds the decoded request URI.
93
+ */
94
+ public static string $decodedUri = '';
95
+
91
96
  /**
92
97
  * @var string $referer Holds the referer of the request.
93
98
  */
@@ -452,4 +457,16 @@ class Request
452
457
 
453
458
  exit;
454
459
  }
460
+
461
+ public static function getDecodedUrl(string $uri): string
462
+ {
463
+ $parsedUrl = parse_url($uri);
464
+
465
+ $queryString = isset($parsedUrl['query']) ? '?' . urldecode($parsedUrl['query']) : '';
466
+ $path = $parsedUrl['path'] ?? '';
467
+
468
+ $decodedUrl = urldecode($path . $queryString);
469
+
470
+ return $decodedUrl;
471
+ }
455
472
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma-php-app",
3
- "version": "2.0.0-beta.12",
3
+ "version": "2.0.0-beta.14",
4
4
  "description": "Prisma-PHP: A Revolutionary Library Bridging PHP with Prisma ORM",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",