If you use the same value for subdomain as domain, the detector will misunderstand it as subdomain: for example you use localhost for subdomain modifier value, then when you run http://localhost the PURL will detect the domain as subdomain and all urls are rewrote to http://localhost.localhost and mess the whole site up.

Maybe this one will fix the problem

  function detect($q) {
    $parts = explode('.', str_replace('http://','',$_SERVER['HTTP_HOST']));

    if (count($parts) <= 2) {
      return null;
    }

    return array_shift($parts);
  }

Comments

yhahn’s picture

Assigned: Unassigned » yhahn
Category: bug » task

Hm, so a fix for this is not trivial. Looking into the problem space, we need to be able to determine what is a proper top level domain and what is not (see https://wiki.mozilla.org/TLD_List).

nquocbao’s picture

or maybe we just ignore this bug, consider it as "known issues". PURL should work as fast as possible ?

jmiccolis’s picture

Priority: Critical » Normal
Status: Active » Postponed

I'm in the "known issue" camp here. I'm quite sure there is a much much much smarter way we could represent URIs inside of PURL that would make solving these sorts of issues moot. However sure it'll be a lot of work, and I'm not sure it's worth the effort for 95% of use cases.

Setting this to postponed, for now, we should revisit this later when we get the time to revisit PURL's internals.