generated from nathanwoodburn/python-webserver-template
feat: Add support for emojis
This commit is contained in:
@@ -211,6 +211,23 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Convert unicode/emoji to punycode for Handshake names
|
||||||
|
function toPunycode(name) {
|
||||||
|
// Check if name contains non-ASCII characters
|
||||||
|
if (!/[^\x00-\x7F]/.test(name)) {
|
||||||
|
return name; // Already ASCII, no conversion needed
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Use the browser's built-in URL API to convert to punycode
|
||||||
|
const url = new URL(`http://${name}`);
|
||||||
|
return url.hostname;
|
||||||
|
} catch {
|
||||||
|
// Fallback: return original if conversion fails
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Format chain data nicely
|
// Format chain data nicely
|
||||||
function formatChainData(chain) {
|
function formatChainData(chain) {
|
||||||
return `
|
return `
|
||||||
@@ -1021,8 +1038,9 @@
|
|||||||
alert('Please enter a name');
|
alert('Please enter a name');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
updateURL('name', name);
|
const punyName = toPunycode(name);
|
||||||
const data = await apiCall(`name/${name}`);
|
updateURL('name', punyName);
|
||||||
|
const data = await apiCall(`name/${punyName}`);
|
||||||
|
|
||||||
// Use formatted display
|
// Use formatted display
|
||||||
const resultElement = document.getElementById('name-result');
|
const resultElement = document.getElementById('name-result');
|
||||||
@@ -1039,7 +1057,8 @@
|
|||||||
alert('Please enter a name');
|
alert('Please enter a name');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const data = await apiCall(`nameresource/${name}`);
|
const punyName = toPunycode(name);
|
||||||
|
const data = await apiCall(`nameresource/${punyName}`);
|
||||||
|
|
||||||
// Use formatted display
|
// Use formatted display
|
||||||
const resultElement = document.getElementById('name-result');
|
const resultElement = document.getElementById('name-result');
|
||||||
@@ -1056,7 +1075,8 @@
|
|||||||
alert('Please enter a name');
|
alert('Please enter a name');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const data = await apiCall(`namesummary/${name}`);
|
const punyName = toPunycode(name);
|
||||||
|
const data = await apiCall(`namesummary/${punyName}`);
|
||||||
|
|
||||||
// Use formatted display
|
// Use formatted display
|
||||||
const resultElement = document.getElementById('name-result');
|
const resultElement = document.getElementById('name-result');
|
||||||
|
|||||||
Reference in New Issue
Block a user