Last Updated: February 25, 2016
·
4.98K
· iamjohnjensen

Remove ugly #_=_ string from URL when using Facebook OmniAuth

I was recently working on a Ruby on Rails project with the OmniAuth gem to provide Facebook Authentication.

When redirected from Facebook back to my application the URL contained this ugly/pesky little string:

e.g. www.mysite.com/logged-in#_=_

This piece of javascript will find this string and rewrite with with nothing ‘ ‘ on document .ready

$(document).ready(function () {
if (window.location.href.indexOf('#_=_') > 0) {
window.location = window.location.href.replace(/#.*/, '');
}});

This can be easily placed within your app/assets/application.js to globally rewrite this.

1 Response
Add your response

Thanks for sharing, I'll implement this ASAP - I agree it does look ugly.

over 1 year ago ·