에셋 리로드 파일별 캐시 검증 보강
This commit is contained in:
+22
-7
@@ -1,11 +1,26 @@
|
||||
<?php
|
||||
|
||||
function h($value): string
|
||||
{
|
||||
return htmlspecialchars((string)($value ?? ''), ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
|
||||
function won($value): string
|
||||
function h($value): string
|
||||
{
|
||||
return htmlspecialchars((string)($value ?? ''), ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
|
||||
function asset_url(string $path): string
|
||||
{
|
||||
$publicRoot = realpath(__DIR__ . '/../../public');
|
||||
$fullPath = $publicRoot ? $publicRoot . '/' . ltrim($path, '/') : '';
|
||||
$version = 'dev';
|
||||
|
||||
if ($fullPath !== '' && is_file($fullPath)) {
|
||||
$mtime = filemtime($fullPath) ?: time();
|
||||
$hash = is_readable($fullPath) ? substr(hash_file('sha256', $fullPath) ?: '', 0, 10) : '';
|
||||
$version = $mtime . ($hash !== '' ? '-' . $hash : '');
|
||||
}
|
||||
|
||||
return $path . '?v=' . rawurlencode($version);
|
||||
}
|
||||
|
||||
function won($value): string
|
||||
{
|
||||
return number_format((float)$value, 0) . '원';
|
||||
}
|
||||
@@ -95,4 +110,4 @@ function get_flash_message(): ?array
|
||||
$flash = $_SESSION['flash_message'];
|
||||
unset($_SESSION['flash_message']);
|
||||
return $flash;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user