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

BP ticket
https://redmine.openpne.jp/issues/3658
Bug ticket
https://redmine.openpne.jp/issues/1632