Seemingly unneccessary array_reverse call in Www middleware
BlakeHancock opened this issue · 4 comments
Whether it is called or not has no affect on the return of the canAddWww function as the only time an array index is used is when there are 3 values and it checks the centre one.
Unless I'm missing something.
This is to handle hosts with multiple subdomains. Imagine this host: m.subdomain.example.co.uk
. To get the value of co
, it's easier if it has always the index 1
instead to calculate the index of the second last element of the array.
Changed the code to use array_slice
only if it's neccesary
😄
It's in a switch count of 3 though, so the domain "m.subdomain.example.co.uk" would always fall through the default since it's count would be 5. $host[1] is always going to be the "co" in a switch count of 3.
Oops, you're right. I don't know why, but I was seeing this case as the default case, instead count of 3 case.