My brain assumes that the first block handles the case of the url being an https one if I read http in the condition. Swap them and negate the condition for better readability. This might be a symptom of this condition being to complex, but well - it's shell scripting ¯\_(ツ)_/¯