BBD-451: Update URL beautifiers to support full URL spec#199
BBD-451: Update URL beautifiers to support full URL spec#199Guo-Haowei wants to merge 34 commits intodevelopfrom
Conversation
This reverts commit c0607b7.
…nements instead of using '='
to remove prefix without reconstructing and reparsing url
| } | ||
| } else { | ||
| if (paths.length < 2) { | ||
| throw new Error('path has wrong number of parts'); |
There was a problem hiding this comment.
I would say "path has too few parts" or "path has fewer than two parts"
There was a problem hiding this comment.
I don't think it needs to be changed because the paths in this context excluded productId and productTiltle, so the actual path length is longer than 2.
| }); | ||
| } | ||
| } | ||
| result['refinements'] = refinements; |
There was a problem hiding this comment.
Use result.refinements and add a blank line before.
There was a problem hiding this comment.
I've already changed it to result.refinements.
effervescentia
left a comment
There was a problem hiding this comment.
Looks good, a couple of small fixes here and there
| return `/${paths.map((path) => encodeURIComponent(path.replace(/\s/g, '-'))).join('/')}`; | ||
| } | ||
|
|
||
| private refinementsComparator(refinement1: SelectedValueRefinement, refinement2: SelectedValueRefinement): number { |
| }, {}); | ||
|
|
||
| detail.refinements.sort(this.refinementsComparator).forEach((refinement) => { | ||
| if (!(refinement.navigationName in refinementsToKeys)) |
| } | ||
| } | ||
|
|
||
| paths.push(detail.productID); |
There was a problem hiding this comment.
support for query parameter here
| import { Beautifier, BeautifierConfig, Detail } from './interfaces'; | ||
| import { SelectedValueRefinement } from 'groupby-api'; | ||
|
|
||
| export class DetailUrlGenerator { |
| } | ||
| } | ||
|
|
||
| export class DetailUrlParser { |
|
|
||
| while (path.length > 0) { | ||
| const value = this.decode(path.shift()); | ||
| const navigationName = path.shift(); |
There was a problem hiding this comment.
only decode the one?
| } | ||
|
|
||
| private extractRefinements(refinementString: string, navigationName: string): SelectedValueRefinement[] { | ||
| const refinementStrings = refinementString.split('~'); |
| navigation: '/navigation' | ||
| } | ||
| }; | ||
| private queryGenerator: QueryUrlGenerator = new QueryUrlGenerator(this); |
There was a problem hiding this comment.
maybe use factory pattern here
| } | ||
| keys.push(key); | ||
| } | ||
| if (this.config.queryToken.length !== 1) { |
| } | ||
|
|
||
| build(query: Query) { | ||
| return this.queryGenerator.build(query); |
There was a problem hiding this comment.
build() already exists (buildQueryUrl())
Please review.