Skip to content

Commit

Permalink
fix(removeHighlightTags): prevent destructuring undefined object (#…
Browse files Browse the repository at this point in the history
…1039)

Co-authored-by: Haroen Viaene <hello@haroen.me>
  • Loading branch information
shortcuts and Haroenv committed Aug 19, 2021
1 parent 04878d7 commit 6a6f7f6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions packages/docsearch-react/package.json
Expand Up @@ -34,8 +34,8 @@
"watch": "watch \"yarn on:change\" --ignoreDirectoryPattern \"/dist/\""
},
"dependencies": {
"@algolia/autocomplete-core": "1.2.1",
"@algolia/autocomplete-preset-algolia": "1.2.1",
"@algolia/autocomplete-core": "1.2.2",
"@algolia/autocomplete-preset-algolia": "1.2.2",
"@docsearch/css": "3.0.0-alpha.39",
"algoliasearch": "^4.0.0"
},
Expand Down
16 changes: 8 additions & 8 deletions packages/docsearch-react/src/utils/removeHighlightTags.ts
Expand Up @@ -6,17 +6,17 @@ const regexHasHighlightTags = RegExp(regexHighlightTags.source);
export function removeHighlightTags(
hit: DocSearchHit | InternalDocSearchHit
): string {
if (
!(hit as InternalDocSearchHit).__docsearch_parent &&
!hit._highlightResult
) {
const internalDocSearchHit = hit as InternalDocSearchHit;

if (!internalDocSearchHit.__docsearch_parent && !hit._highlightResult) {
return hit.hierarchy.lvl0;
}

const { value } = hit._highlightResult
? hit._highlightResult.hierarchy.lvl0
: (hit as InternalDocSearchHit).__docsearch_parent!._highlightResult
.hierarchy.lvl0;
const { value } =
(internalDocSearchHit.__docsearch_parent
? internalDocSearchHit.__docsearch_parent?._highlightResult?.hierarchy
?.lvl0
: hit._highlightResult?.hierarchy?.lvl0) || {};

return value && regexHasHighlightTags.test(value)
? value.replace(regexHighlightTags, '')
Expand Down
28 changes: 14 additions & 14 deletions yarn.lock
Expand Up @@ -2,24 +2,24 @@
# yarn lockfile v1


"@algolia/autocomplete-core@1.2.1":
version "1.2.1"
resolved "https://registry.yarnpkg.com/@algolia/autocomplete-core/-/autocomplete-core-1.2.1.tgz#95fc07cfa40b5a38e3f80acd75d1fb94968215a8"
integrity sha512-/SLS6636Wpl7eFiX7eEy0E3wBo60sUm1qRYybJBDt1fs8reiJ1+OSy+dZgrLBfLL4mSFqRIIUHXbVp25QdZ+iw==
"@algolia/autocomplete-core@1.2.2":
version "1.2.2"
resolved "https://registry.yarnpkg.com/@algolia/autocomplete-core/-/autocomplete-core-1.2.2.tgz#c121e70c78fd0175c989a219918124ad7758e48b"
integrity sha512-JOQaURze45qVa8OOFDh+ozj2a/ObSRsVyz6Zd0aiBeej+RSTqrr1hDVpGNbbXYLW26G5ujuc9QIdH+rBHn95nw==
dependencies:
"@algolia/autocomplete-shared" "1.2.1"
"@algolia/autocomplete-shared" "1.2.2"

"@algolia/autocomplete-preset-algolia@1.2.1":
version "1.2.1"
resolved "https://registry.yarnpkg.com/@algolia/autocomplete-preset-algolia/-/autocomplete-preset-algolia-1.2.1.tgz#bda1741823268ff76ba78306259036f000198e01"
integrity sha512-Lf4PpPVgHNXm1ytrnVdrZYV7hAYSCpAI/TrebF8UC6xflPY6sKb1RL/2OfrO9On7SDjPBtNd+6MArSar5JmK0g==
"@algolia/autocomplete-preset-algolia@1.2.2":
version "1.2.2"
resolved "https://registry.yarnpkg.com/@algolia/autocomplete-preset-algolia/-/autocomplete-preset-algolia-1.2.2.tgz#da734ef9e42a5f64cdad2dfc81c4e9fbf805d976"
integrity sha512-AZkh+bAMaJDzMZTelFOXJTJqkp5VPGH8W3n0B+Ggce7DdozlMRsDLguKTCQAkZ0dJ1EbBPyFL5ztL/JImB137Q==
dependencies:
"@algolia/autocomplete-shared" "1.2.1"
"@algolia/autocomplete-shared" "1.2.2"

"@algolia/autocomplete-shared@1.2.1":
version "1.2.1"
resolved "https://registry.yarnpkg.com/@algolia/autocomplete-shared/-/autocomplete-shared-1.2.1.tgz#96f869fb2285ed6a34a5ac2509722c065df93016"
integrity sha512-RHCwcXAYFwDXTlomstjWRFIzOfyxtQ9KmViacPE5P5hxUSSjkmG3dAb77xdydift1PaZNbho5TNTCi5UZe0RpA==
"@algolia/autocomplete-shared@1.2.2":
version "1.2.2"
resolved "https://registry.yarnpkg.com/@algolia/autocomplete-shared/-/autocomplete-shared-1.2.2.tgz#ff25dc308f2a296b2b9b325f1e3b57498eea3e0c"
integrity sha512-mLTl7d2C1xVVazHt/bqh9EE/u2lbp5YOxLDdcjILXmUqOs5HH1D4SuySblXaQG1uf28FhTqMGp35qE5wJQnqAw==

"@algolia/cache-browser-local-storage@4.10.3":
version "4.10.3"
Expand Down

0 comments on commit 6a6f7f6

Please sign in to comment.