fixed removal of trailing slash is not enough. (refs 3633, BP from #1632)

Backport
https://redmine.openpne.jp/issues/3633
( backport from https://redmine.openpne.jp/issues/1632 )