Skip to content

Subdomain elevator same as first domain elevator #339

@typeoneerror

Description

@typeoneerror

I noticed that the Subdomain elevator first parses the subdomains and then returns the first one in the list in https://github.com/influitive/apartment/blob/development/lib/apartment/elevators/subdomain.rb#L37.

Examples:

  • "bar.foo.com" would be ["bar"] and "bar" would be the subdomain.
  • "baz.bar.foo.com" would be ["baz", "bar"] and "baz" would be the subdomain.

Base on the FirstSubdomain elevator, this seems like exactly the same since the FirstSubdomain just splits on "." and returns the first item. Seeing that we always get first in Subdomain, should link 37 not be something line:

def subdomain(host)
  subdomains(host).join('.')
end

This way, following our example

  • "bar.foo.com" would be ["bar"] and "bar" would be the subdomain/schema name
  • "baz.bar.foo.com" would be ["baz", "bar"] and "baz.bar" would be the subdomain/schema name

FirstDomain should continue to work because in both cases, we'd still get "bar" and "baz".

Not sure if I'm mis-reading Subdomain implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions