In community.wanikani.com, opening any links to topics with Japanese in the fully qualified URL stopped working when opening them in a new tab or directly copying and pasting the link. Clicking the link to navigate within the same tab still works.
For example, opening this link in a new tab should navigate to
If the link happens to match exactly, it works fine. But of course with topic renames this is often not the case.
I also tried to reproduce on try.discourse.org, but on that install Japanese characters never get added to the URL even when included in the topic title. I’m not sure why that’s the case, but without that happening I can’t demonstrate the bug there.
sigh It looks like it might be yet another Chrome bug. It works fine for me in both Firefox and Edge. Weirdly it works the first time in an incognito window, but then fails the second time. Same thing after clearing site cache/cookies and restarting my computer.
Would you mind checking in Chrome to confirm if it’s an issue there in general and not just a problem for me? Just be sure to try to open the page multiple times since the first one seems to work fine. I appreciate the help!
Still with Chrome? Just want to be sure before reporting it to them. I assume nothing changed related to this recently on Discourse? (Regardless, this would probably still be a Chrome issue since it just happens there, even if something did change on Discourse.)
Well scratch that. It started happening again today. I have no idea how it got fixed for a bit.
Since this might take a while, I’d be open to workarounds for now. I mentioned in the OP about how on try (and I checked here on meta too) the Japanese characters never get added to the URL, effectively circumventing this issue. Is that a site or category setting that I can talk to my site admin about? Any other suggestions for a workaround besides that?
I have dig into our codebase and looks like the error is kinda simple, but I would like to verify my assumptions.
We have a site setting named slug_generation_method which must be changed from the default ascii value to encoded in order to trigger this bug. When you change this site setting, we clear all slugs and generate those again.
What I don’t understand is why when the site setting is set to “encoded” we generate a slug like this:
The raw slug from the table is returned in the Location header 301 response when a topic slug doesn’t match, and IMO we should return a valid URL in there.
So are you saying the URL itself would show the encoded version? Or just that the redirect would internally handle it by using the encoded version? Either way, getting this to “just work” and not rely on browser quirks would be great.
슬러그 생성 설정이 **인코딩(encoded)**으로 되어 있을 때, 슬러그 컬럼에 실제 인코딩된 슬러그를 저장합니다. 인코딩된 슬러그를 사용하는 경우 현재 모든 슬러그를 비워두는 마이그레이션을 수행하여 시간이 지나면서 슬러그가 올바르게 재생성되도록 합니다.
현재 UTF-8 슬러그를 유지하고, 301 리다이렉트 헤더로 전송할 때 실시간으로 패치합니다.
개인적으로 1번이 "더 정확"하다고 생각하며, 이는 클라이언트에 원본 슬러그를 전달하는 것을 더 어렵게 만듭니다. 그러나 슬러그 생성기만 패치하는 것만으로는 충분하지 않았습니다. 브라우저는 301 리다이렉트에서 인코딩된 URL을 받지만 다음 요청 시 이를 디코딩하기 때문에, 우리의 슬러그 비교가 실패하고 다시 리다이렉트가 발생합니다. 즉, 토픽 컨트롤러의 슬러그 비교 메서드도 패치해야 하고, 다른 곳들도 마찬가지일 것입니다.