An alternative is to do something like this:

* If there's a slash, split on the first one to find (A) username and (B) repo[/subdir][#pull|@ref]
* Take part B and split on # or @ to find a pull or ref.

You might need some logic to make sure that there isn't a pull and a ref, and perhaps for other forms of bad input. I think it should be possible to construct a relatively simple validation regexp for this purpose.