If you use letters with diacritic, you should use the encoded URI for that.
For example:
instead of Å use: %C3%85
instead of Ä use %C3%84
and instead of Ö use %C3%96
To do the conversion you use the encodeURI function:
path = encodeURI(pathUrl)
But your solution should work as well.