Prefer pathname methods over regexp matching