fix detect query type with whitespace prefix