Skip to content

Conversation

@pshoukry
Copy link

@pshoukry pshoukry commented Jan 1, 2026

Problem

The remove_special_chars/1 function in TailwindCompiler 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 when pages have non-Latin paths.

Error example:

Error: ENOENT: no such file or directory, open '/tmp/.../abc_page__blog_�_�_ت�_�_�_�_.template'

Solution

Hash non-ASCII paths using :erlang.phash2/1 to create safe ASCII-only filenames, while preserving the existing behavior for ASCII-only paths.

Before:

defp remove_special_chars(name), do: String.replace(name, ~r/[^[:alnum:]_]+/, "_")

After:

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

Testing

  • Tested with Arabic page paths (e.g., /مدونة)
  • Fixes boot crash on Fly.io deployment

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 `/博客`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant