Remove internal options from query string of paths

Fixes #17057
Merge pull request #17058 from eval/issue-17057

Remove internal options from query string of paths
Keep the original implementation to not having to allocate new objects