From f4cdc51afb19892823423a4040b01395659ebc9f Mon Sep 17 00:00:00 2001 From: Peter Shoukry Date: Thu, 1 Jan 2026 13:14:27 +0200 Subject: [PATCH] fix: handle non-ASCII characters in page paths for Tailwind compilation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `remove_special_chars/1` function uses `[^[:alnum:]_]` regex which allows Unicode letters (Arabic, Chinese, etc.) through. The Tailwind CLI binary cannot handle UTF-8 filenames, causing ENOENT errors during boot. This fix hashes non-ASCII paths using `:erlang.phash2/1` to create safe ASCII-only filenames, while preserving the existing behavior for ASCII paths. Fixes boot crash when pages have non-Latin paths like `/مدونة` or `/博客`. --- lib/beacon/tailwind_compiler.ex | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/beacon/tailwind_compiler.ex b/lib/beacon/tailwind_compiler.ex index 5ff0bf77..d0476507 100644 --- a/lib/beacon/tailwind_compiler.ex +++ b/lib/beacon/tailwind_compiler.ex @@ -257,7 +257,15 @@ defmodule Beacon.RuntimeCSS.TailwindCompiler do input_css_path end - defp remove_special_chars(name), do: String.replace(name, ~r/[^[:alnum:]_]+/, "_") + # The Tailwind CLI binary cannot handle UTF-8 filenames, so we hash + # any paths containing non-ASCII characters (Arabic, Chinese, etc.) + defp remove_special_chars(name) do + if String.match?(name, ~r/[^\x00-\x7F]/) do + "_hash_#{:erlang.phash2(name)}" + else + String.replace(name, ~r/[^a-zA-Z0-9_]+/, "_") + end + end # include paths for the following scenarios: # - regular app