Refactor URI component matching to its own method