Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(removeHighlightTags): prevent destructuring undefined object #1039

Merged
merged 3 commits into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/docsearch-react/package.json
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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) || '';
shortcuts marked this conversation as resolved.
Show resolved Hide resolved

return value && regexHasHighlightTags.test(value)
? value.replace(regexHighlightTags, '')
Expand Down
28 changes: 14 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
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