Skip to content

Commit 2a9d85d

Browse files
committed
Fix non-ASCII URL conversion
* Apparently, I introduced a regression at some point that caused bytes to be appended with a hyphen that broke the conversion
1 parent 65f837e commit 2a9d85d

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

contrib/compose/nginx_medium_rewrite_urls.conf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,12 @@ server {
6565
-- Keep safe ASCII characters as is
6666
encoded = encoded .. string.char(byte)
6767
else
68-
-- For all other bytes, use the -XX format
69-
encoded = encoded .. "-" .. string.format("%02x", byte):lower()
68+
-- For all other bytes except the first one, use the -XX format
69+
if #encoded > 0 then
70+
encoded = encoded .. "-" .. string.format("%02x", byte):lower()
71+
else
72+
encoded = encoded .. string.format("%02x", byte):lower()
73+
end
7074
end
7175
end
7276
table.insert(encoded_parts, encoded)

nginx.conf.sigil

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,12 @@ server {
124124
-- Keep safe ASCII characters as is
125125
encoded = encoded .. string.char(byte)
126126
else
127-
-- For all other bytes, use the -XX format
128-
encoded = encoded .. "-" .. string.format("%02x", byte):lower()
127+
-- For all other bytes except the first one, use the -XX format
128+
if #encoded > 0 then
129+
encoded = encoded .. "-" .. string.format("%02x", byte):lower()
130+
else
131+
encoded = encoded .. string.format("%02x", byte):lower()
132+
end
129133
end
130134
end
131135
table.insert(encoded_parts, encoded)

0 commit comments

Comments
 (0)