udleinati / redirect.center

Redirect domains using DNS only
http://redirect.center
MIT License
257 stars 49 forks source link

Dot "." in the path after the / #19

Closed kenttregenza closed 7 years ago

kenttregenza commented 7 years ago

I've noticed just recently that you may have changed your parsing method for the path after "opts-slash". Before something like this worked. sites.google.com.opts-slash.example.com.opts-slash.sub-path
=> sites.google.com/example.com/sub-path

But now this => sites.google.com.com/example/sub-path

My guess is you aren't grabbing things between the .opts-slash

Perhaps this?

Do this before to get rid of the FQDN hostname = hostname.replace(new RegExp(.${config.fqdn}+ '$'), '')

Then do your status code parsing

Then do your slash parsing using an exec reg exp

re = /(\.(?:opts-)?slash\.)(.*?)(?:(?:\.(?:opts-)?slash\.)|$)/ig
r = re.exec(hostname)
while(r) {
   hostname = hostname.replace(`${r[1]}${r[2]}`, "")
   options.slashs.push(r[2])
   this.logger.info(`${path} ${hostname} without ${r[1]}.${r[2]}`)
  re.lastIndex = 0   // To reset exec
  r = re.exec(hostname)
}

This matches both .slash. and .opts-slash.

udleinati commented 7 years ago

@kenttregenza I'm sorry for this mistake. I released a new version of redirect.center in javascript yesterday. I changed the code parsing and now is working fine. Thanks