Add 'query' option to allow query strings in fragment

Fixes #2801