Workaround for IDNA problems with Disqus commenting

I’m using Disqus commenting service for both my blogs, which has been great. However the Finnish one lies under IDNA domain name (niemelä.fi) and that has been causing some problems. I noticed that some of the comments were missing and that seemed to depend on which web browser was used.

Disqus maps blog post urls to discussions saved in the service and by default it fetches post url using window.location.href value. Firefox returns that in Unicode format eg. niemelä.fi, while Chrome uses ascii punycode xn– This behaviour will save two different discussion threads from same post. One for Firefox users and other for Chrome users.

Fortunately Disqus allows overriding the post url using disqus_url variable and Punycode.js library provides Javascript encoding/decoding functions for IDNA domain names. Workaround is following:

var disqus_url = "http://" + punycode.toASCII( + window.location.pathname;

punycode.toASCII() function will convert domain name only when it’s in unicode format so it will be safe to call it always.

I merged older comment threads using migration tools at Disqus by uploading url mapping file in CSV format after aplying this workaround.

comments powered by Disqus