use a ternary assignment for query portion

to avoid calling [0] on null when pth.match(QUERY) doesn't match anything.