Search code examples
searchidn

Buiding a search for IDNA domains


We are upgrading our systems for IDNA support but I'm currently struggling with our domain search. In our domain portfolio you can search for domains. IDNA domains are saved as their A-label in our database (café-modern.com is saved as xn--caf-modern-d7a.com) and we just convert it to the U-label when displaying it in the browser.

Problem is that this totally breaks our search.
When someone searches for café-modern.com I can easily convert it to the IDNA value and use that in the WHERE domain_name LIKE ? part of the DB-query but when someone searches just for café (xn--caf-dma) that should also find café-modern.com

A solution would be to save both the A-label and U-label values in the database but that's somehing I would want to keep as a last resort because the dataset is quite large and I would like to keep the database schema as simple as possible.


Solution

  • It is so normal. I have been using a similar system. I think your design is incorrect. Should not save as like (xn--caf-modern-d7a.com), You can save as like (café-modern.com) on DB. You have to convert from IDNA value to UTF8 value(or another one) when you are recording on DB. Thus, you can search café-modern.com and café in the WHERE domain_name LIKE ?