Skip to content

Commit

Permalink
Merge pull request #63 from vtex-apps/fix/search-encode-uri
Browse files Browse the repository at this point in the history
Fix encode order for searchEncodeURI
  • Loading branch information
Jeymisson authored Mar 18, 2020
2 parents 649c712 + 36c271f commit 10cd3f4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed
- Encode order for searchEncodeURI

## [0.20.3] - 2020-03-18
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"vendor": "vtex",
"name": "search-graphql",
"version": "0.20.3",
"version": "0.20.4-beta.0",
"title": "GraphQL API for the VTEX store APIs",
"description": "GraphQL schema and resolvers for the VTEX API for the catalog and orders.",
"credentialType": "absolute",
Expand Down
14 changes: 6 additions & 8 deletions node/clients/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export class Search extends AppClient {
public facets = (facets: string = '') => {
const [path, options] = decodeURI(facets).split('?')
return this.get<SearchFacets>(
`/pub/facets/search/${this.searchEncodeURI(encodeURI(
`/pub/facets/search/${encodeURI(this.searchEncodeURI(
`${path.trim()}${options ? '?' + options : ''}`
))}`,
{ metric: 'search-facets' }
Expand All @@ -181,9 +181,9 @@ export class Search extends AppClient {

public autocomplete = ({ maxRows, searchTerm }: AutocompleteArgs) =>
this.get<{ itemsReturned: SearchAutocompleteUnit[] }>(
`/buscaautocomplete?maxRows=${maxRows}&productNameContains=${this.searchEncodeURI(
encodeURIComponent(searchTerm)
)}`,
`/buscaautocomplete?maxRows=${maxRows}&productNameContains=${
encodeURIComponent(this.searchEncodeURI(searchTerm))
}`,
{ metric: 'search-autocomplete' }
)

Expand Down Expand Up @@ -235,10 +235,8 @@ export class Search extends AppClient {
hideUnavailableItems = false,
simulationBehavior = SimulationBehavior.DEFAULT,
}: SearchArgs) => {
const sanitizedQuery = this.searchEncodeURI(
encodeURIComponent(
decodeURIComponent(query || '').trim()
)
const sanitizedQuery = encodeURIComponent(
this.searchEncodeURI(decodeURIComponent(query || '').trim())
)
if (hideUnavailableItems) {
const segmentData = (this.context as CustomIOContext).segment
Expand Down

0 comments on commit 10cd3f4

Please sign in to comment.