Fix Bug 974653 - Translation Bar should use relative redirect #1717

Merged
merged 1 commit into from Feb 25, 2014

Projects

None yet

4 participants

@kyoshino
Member

No description provided.

@kyoshino
Member

Needs a regex to support non-www.mozilla.org sites as @alexgibson said 👍

@alexgibson
Member

I've given this some testing and it seems to work ok.

The only thing I'm unsure on, would this still work ok if the host contained a port number? It wouldn't be a real issue for us here, but worth querying I suppose.

For example, when I test locally the relative link gets changed to :8000/en-US/. Perhaps this is an edge-case we don't need worry about though.

@alexgibson
Member

As an alternative to using a regex, I was going to suggest creating a link element, and then using the protocol and host properties, but perhaps a regex here is actually simpler on second thought :)

@pmclanahan pmclanahan and 2 others commented on an outdated diff Feb 24, 2014
bedrock/tabzilla/templates/tabzilla/tabzilla.js
@@ -416,7 +416,7 @@ var Tabzilla = (function (Tabzilla) {
trackLabel: userLang,
callback: function () {
if (langLink.length) {
- location.href = langLink.attr('href');
+ location.href = langLink.attr('href').replace(/^https?\:\/\/[\w\.\-]+/, '');
@pmclanahan
pmclanahan Feb 24, 2014 Mozilla member

If we want to support all possible domains as well as a custom port, we can open this up a bit and just do: /^https?\:\/\/[^/]+/

@jgmize
jgmize Feb 24, 2014 Mozilla member

nice regex-fu, @pmclanahan 👍

@kyoshino
kyoshino Feb 25, 2014 Mozilla member

Thanks @pmclanahan [^^]/ It should work. Updated the PR.

@alexgibson
Member

Tested the update locally and seems to be working well, thanks @kyoshino and @pmclanahan!

r+

@alexgibson alexgibson merged commit d7bcb8d into mozilla:master Feb 25, 2014

1 check passed

Details default Jenkins build 'bedrock_github' #3309 has succeeded
@kyoshino kyoshino deleted the kyoshino:bug-974653-transbar-relative-redirect branch Feb 27, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment