Skip to content

ress_annotation_tags returns wrong alternate urls if canonical version has a subdomain configured #1

Closed
m4n opened this Issue Feb 25, 2013 · 4 comments

2 participants

@m4n
m4n commented Feb 25, 2013

Given the following Ress configuration:

Ress.configure do |config|
  config.set_canonical :subdomain => "www"
  config.add_alternate :name  => "mobile", :media => "foo"
end

When I go to "http://www.example.com/" (a canonical url) then the ress_annotation_tags view helper should return

<link href="http://mobile.example.com/" id="mobile" 
   media="foo" rel="alternate" />

but it instead returns

<link href="http://mobile.www.example.com/" id="mobile" 
   media="foo" rel="alternate" />

Having the canonical subdomain in the alternate version url seems like a bug to me.

@matthewrobertson
Owner

@m4n currently this is expected behaviour. My intention for the canonical subdomain was to support sites served under subdomains other than www. EG my company's app is servered under secure.medeo.ca so we want the mobile version to be at m.secure.medeo.ca. We always set up a permanent redirect away from the www subdomain.

All that said, I think there is a strong argument for allowing a configuration option that sets the alternate version subdomains to replace the canonical. This shouldn't be too much work. I could probably get it in to master in a couple of days, or if you would like you could try to dig in yourself and submit a pull request.

@matthewrobertson
Owner

OK I have added a configuration option to achieve the behaviour you suggested. If you update to ress "~> 0.0.10" and add:

config.replace_canonical_subdomain = false

to your config/initializers/ress.rb it should do what you want. Please let me know if you have any more issues.

@m4n
m4n commented Feb 26, 2013

Matthew, thanks for implementing this feature. It works fine.

What about

config.set_canonical :subdomain => "www", :replace => true

instead of your config solution?

@matthewrobertson
Owner

Good idea, I think I like that better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.