@usereactify/search 5.14.0 → 5.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [5.14.1](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.14.0...release-v5.14.1) (2022-12-01)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * properly encode search query when submitting ([3ecc44f](https://bitbucket.org/usereactify/reactify-search-ui/commit/3ecc44fd72ebe4ea3bc919bf1d823b0a49bc0830))
11
+
5
12
  ## [5.14.0](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.13.0...release-v5.14.0) (2022-11-28)
6
13
 
7
14
 
package/dist/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@usereactify/search",
3
3
  "description": "React UI library for Reactify Search",
4
- "version": "5.14.0",
4
+ "version": "5.14.1",
5
5
  "license": "MIT",
6
6
  "main": "dist/src/index.js",
7
7
  "types": "dist/src/index.d.ts",
@@ -28,13 +28,15 @@ const useSearch = () => {
28
28
  }
29
29
  search.setShowInstantSearchResults(false);
30
30
  if (options.onRedirect) {
31
- options.onRedirect(redirect ? "redirect" : "search", redirect ? redirect.url : `/search?q=${searchTerm}`);
31
+ options.onRedirect(redirect ? "redirect" : "search", redirect
32
+ ? redirect.url
33
+ : `/search?q=${encodeURIComponent(searchTerm)}`);
32
34
  }
33
35
  else if (redirect) {
34
36
  window.location.href = redirect.url;
35
37
  }
36
38
  else {
37
- window.location.href = `/search?q=${searchTerm}`;
39
+ window.location.href = `/search?q=${encodeURIComponent(searchTerm)}`;
38
40
  }
39
41
  }, [search.searchTerm]);
40
42
  const handleSetSearchTerm = react_1.default.useCallback((searchTerm = "") => {
@@ -1 +1 @@
1
- {"version":3,"file":"useSearch.js","sour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IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC;SACrC;aAAM;YACL,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,aAAa,UAAU,EAAE,CAAC;SAClD;IACH,CAAC,EACD,CAAC,MAAM,CAAC,UAAU,CAAC,CACpB,CAAC;IAEF,MAAM,mBAAmB,GAAG,eAAK,CAAC,WAAW,CAC3C,CAAC,aAAqB,EAAE,EAAE,EAAE;QAC1B,eAAK,CAAC,GAAG,CAAC,WAAW,EAAE,2BAA2B,EAAE,UAAU,CAAC,CAAC;QAChE,eAAK,CAAC,UAAU,CAAC;YACf,QAAQ,EAAE,QAAQ;YAClB,OAAO,EAAE,cAAc;YACvB,IAAI,EAAE;gBACJ,UAAU,EAAE,UAAU;aACvB;SACF,CAAC,CAAC;QAEH,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IACnC,CAAC,EACD,CAAC,MAAM,CAAC,UAAU,CAAC,CACpB,CAAC;IAEF,OAAO;QACL,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,aAAa,EAAE,mBAAmB;QAClC,gBAAgB,EAAE,sBAAsB;QACxC,wBAAwB,EACtB,CAAC,CAAC,MAAM,CAAC,wBAAwB,IAAI,CAAC,CAAC,MAAM,CAAC,UAAU;QAC1D,2BAA2B,EAAE,MAAM,CAAC,2BAA2B;KAChE,CAAC;AACJ,CAAC,CAAC;AAhFW,QAAA,SAAS,aAgFpB","sourcesContent":["import React from \"react\";\n\nimport { useReactifySearchContext } from \"../hooks\";\nimport { debug } from \"../utility\";\n\nexport const useSearch = (): {\n /** The current search term */\n searchTerm: string;\n /** Function for changing the current search term */\n setSearchTerm: (searchTerm?: string) => void;\n /** Function for navigating to the search page, includes logic for redirects */\n submitSearchTerm: (searchTerm?: string) => void;\n /** Used to determine if instant search results should be displayed */\n showInstantSearchResults: boolean;\n /** Used to manually set the \"showInstantSearchResults\" value */\n setShowInstantSearchResults: React.Dispatch<React.SetStateAction<boolean>>;\n} => {\n const { options, config, search } = useReactifySearchContext();\n\n const handleSubmitSearchTerm = React.useCallback(\n (searchTerm: string = search.searchTerm) => {\n debug.breadcrumb({\n category: \"search\",\n message: \"search submit\",\n data: {\n searchTerm: searchTerm,\n },\n });\n\n debug.log(\"useSearch\", \"submitSearchTerm[query]\", searchTerm);\n\n if (!searchTerm) {\n return;\n }\n\n const redirect = config.redirects.find(\n (redirect) =>\n redirect.query.trim().toLowerCase() ===\n searchTerm.trim().toLowerCase()\n );\n\n if (redirect) {\n debug.log(\"useSearch\", \"submitSearchTerm[redirect]\", redirect);\n }\n\n search.setShowInstantSearchResults(false);\n\n if (options.onRedirect) {\n options.onRedirect(\n redirect ? \"redirect\" : \"search\",\n redirect ? redirect.url : `/search?q=${searchTerm}`\n );\n } else if (redirect) {\n window.location.href = redirect.url;\n } else {\n window.location.href = `/search?q=${searchTerm}`;\n }\n },\n [search.searchTerm]\n );\n\n const handleSetSearchTerm = React.useCallback(\n (searchTerm: string = \"\") => {\n debug.log(\"useSearch\", \"setSearchTerm[searchTerm]\", searchTerm);\n debug.breadcrumb({\n category: \"search\",\n message: \"search query\",\n data: {\n searchTerm: searchTerm,\n },\n });\n\n search.setSearchTerm(searchTerm);\n },\n [search.searchTerm]\n );\n\n return {\n searchTerm: search.searchTerm,\n setSearchTerm: handleSetSearchTerm,\n submitSearchTerm: handleSubmitSearchTerm,\n showInstantSearchResults:\n !!search.showInstantSearchResults && !!search.searchTerm,\n setShowInstantSearchResults: search.setShowInstantSearchResults,\n };\n};\n"]}
1
+ {"version":3,"file":"useSearch.js","sourceRoot":"","sources":["../../../src/hooks/useSearch.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,oCAAoD;AACpD,wCAAmC;AAE5B,MAAM,SAAS,GAAG,GAWvB,EAAE;IACF,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,gCAAwB,GAAE,CAAC;IAE/D,MAAM,sBAAsB,GAAG,eAAK,CAAC,WAAW,CA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,CAAC,aAAqB,EAAE,EAAE,EAAE;QAC1B,eAAK,CAAC,GAAG,CAAC,WAAW,EAAE,2BAA2B,EAAE,UAAU,CAAC,CAAC;QAChE,eAAK,CAAC,UAAU,CAAC;YACf,QAAQ,EAAE,QAAQ;YAClB,OAAO,EAAE,cAAc;YACvB,IAAI,EAAE;gBACJ,UAAU,EAAE,UAAU;aACvB;SACF,CAAC,CAAC;QAEH,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IACnC,CAAC,EACD,CAAC,MAAM,CAAC,UAAU,CAAC,CACpB,CAAC;IAEF,OAAO;QACL,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,aAAa,EAAE,mBAAmB;QAClC,gBAAgB,EAAE,sBAAsB;QACxC,wBAAwB,EACtB,CAAC,CAAC,MAAM,CAAC,wBAAwB,IAAI,CAAC,CAAC,MAAM,CAAC,UAAU;QAC1D,2BAA2B,EAAE,MAAM,CAAC,2BAA2B;KAChE,CAAC;AACJ,CAAC,CAAC;AAlFW,QAAA,SAAS,aAkFpB","sourcesContent":["import React from \"react\";\n\nimport { useReactifySearchContext } from \"../hooks\";\nimport { debug } from \"../utility\";\n\nexport const useSearch = (): {\n /** The current search term */\n searchTerm: string;\n /** Function for changing the current search term */\n setSearchTerm: (searchTerm?: string) => void;\n /** Function for navigating to the search page, includes logic for redirects */\n submitSearchTerm: (searchTerm?: string) => void;\n /** Used to determine if instant search results should be displayed */\n showInstantSearchResults: boolean;\n /** Used to manually set the \"showInstantSearchResults\" value */\n setShowInstantSearchResults: React.Dispatch<React.SetStateAction<boolean>>;\n} => {\n const { options, config, search } = useReactifySearchContext();\n\n const handleSubmitSearchTerm = React.useCallback(\n (searchTerm: string = search.searchTerm) => {\n debug.breadcrumb({\n category: \"search\",\n message: \"search submit\",\n data: {\n searchTerm: searchTerm,\n },\n });\n\n debug.log(\"useSearch\", \"submitSearchTerm[query]\", searchTerm);\n\n if (!searchTerm) {\n return;\n }\n\n const redirect = config.redirects.find(\n (redirect) =>\n redirect.query.trim().toLowerCase() ===\n searchTerm.trim().toLowerCase()\n );\n\n if (redirect) {\n debug.log(\"useSearch\", \"submitSearchTerm[redirect]\", redirect);\n }\n\n search.setShowInstantSearchResults(false);\n\n if (options.onRedirect) {\n options.onRedirect(\n redirect ? \"redirect\" : \"search\",\n redirect\n ? redirect.url\n : `/search?q=${encodeURIComponent(searchTerm)}`\n );\n } else if (redirect) {\n window.location.href = redirect.url;\n } else {\n window.location.href = `/search?q=${encodeURIComponent(searchTerm)}`;\n }\n },\n [search.searchTerm]\n );\n\n const handleSetSearchTerm = React.useCallback(\n (searchTerm: string = \"\") => {\n debug.log(\"useSearch\", \"setSearchTerm[searchTerm]\", searchTerm);\n debug.breadcrumb({\n category: \"search\",\n message: \"search query\",\n data: {\n searchTerm: searchTerm,\n },\n });\n\n search.setSearchTerm(searchTerm);\n },\n [search.searchTerm]\n );\n\n return {\n searchTerm: search.searchTerm,\n setSearchTerm: handleSetSearchTerm,\n submitSearchTerm: handleSubmitSearchTerm,\n showInstantSearchResults:\n !!search.showInstantSearchResults && !!search.searchTerm,\n setShowInstantSearchResults: search.setShowInstantSearchResults,\n };\n};\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@usereactify/search",
3
3
  "description": "React UI library for Reactify Search",
4
- "version": "5.14.0",
4
+ "version": "5.14.1",
5
5
  "license": "MIT",
6
6
  "main": "dist/src/index.js",
7
7
  "types": "dist/src/index.d.ts",