Fix encoding in global search (#2116)

Using plus symbol in global search led to a space in the query parameter of the URL. We now encode the query string properly in global search and additionally fixed the expert search documentation.
This commit is contained in:
Matthias Thieroff
2022-09-14 08:05:31 +02:00
committed by GitHub
parent 30e26b8d4e
commit 54b7b96ac8
6 changed files with 35 additions and 60 deletions

View File

@@ -87,34 +87,13 @@ Standardmäßig werden Repository-Namen um 1,5 und Namespace-Namen um 1,25 geboo
Hinweis: Logische Operatoren müssen in Großbuchstaben eingegeben werden (z. B. „AND").
<table>
<tr>
<th>Definition</th>
<th>Beispiel</th>
</tr>
<tr>
<td>AND beide Terme müssen enthalten sein</td>
<td>Ultimate AND Repository findet z.B. Ultimate Repository, Ultimate Special Repository
</td>
</tr>
<tr>
<td>OR mindestens einer der Terme muss enthalten sein</td>
<td>Ultimate OR Repository findet z.B.. Ultimate Repository, Ultimate User, Special Repository</td>
</tr>
<tr>
<td>NOT der nachfolgende Term darf nicht enthalten sein. „!" kann alternativ verwendet werden.</td>
<td>Ultimate NOT Repository findet z.B.. Ultimate user, nicht jedoch z.B. Ultimate Repository</td>
</tr>
<tr>
<td> schließt den folgenden Term von der Suche aus</td>
<td>Ultimate Repository -Special findet z.B. Ultimate Repository, schließt z.B. Ultimate Special Repository aus</td>
</tr>
<tr>
<td> der folgende Term muss enthalten sein</td>
<td>Ultimate +Repository findet z.B. my Repository, Ultimate Repository</td>
</tr>
</table>
|Operator|Definition|Beispiel|
|--|--|--|
|AND|Beide Terme müssen enthalten sein|Ultimate AND Repository findet z.B. Ultimate Repository, Ultimate Special Repository|
|OR|Mindestens einer der Terme muss enthalten sein|Ultimate OR Repository findet z.B.. Ultimate Repository, Ultimate User, Special Repository|
|NOT|Der nachfolgende Term darf nicht enthalten sein, „!" kann alternativ verwendet werden|Ultimate NOT Repository findet z.B.. Ultimate user, nicht jedoch z.B. Ultimate Repository|
||Schließt den folgenden Term von der Suche aus|Ultimate Repository -Special findet z.B. Ultimate Repository, schließt z.B. Ultimate Special Repository aus|
|+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |Der folgende Term muss enthalten sein|Ultimate +Repository findet z.B. my Repository, Ultimate Repository| </tr>
## Gruppieren

View File

@@ -87,33 +87,13 @@ By default Repository names are boosted by 1.5, namespace by 1.25.
Note: Logical Operators must be entered in upper case (e.g. "AND").
<table>
<tr>
<th>Definition</th>
<th>Example</th>
</tr>
<tr>
<td>AND both terms must be included</td>
<td>Ultimate AND Repository finds e.g. Ultimate Repository, Ultimate Special Repository</td>
</tr>
<tr>
<td>OR at least one of the terms must be included</td>
<td>Ultimate OR Repository finds e.g. Ultimate Repository, Ultimate User, Special Repository</td>
</tr>
<tr>
<td>NOT following term may not be included, "!" may be used alternatively</td>
<td>Ultimate NOT Repository finds e.g. Ultimate user, excludes e.g. Ultimate Repository</td>
</tr>
<tr>
<td> excludes following term from search</td>
<td>Ultimate Repository -Special finds e.g. Ultimate Repository, excludes e.g. Ultimate Special Repository</td>
</tr>
<tr>
<td> following term must be included</td>
<td>Ultimate +Repository finds e.g. my Repository, Ultimate Repository</td>
</tr>
</table>
|Operator |Definition|Example|
|------------|--|--|
|AND|Both terms must be included|\`Ultimate AND Repository\` finds e.g. Ultimate Repository, Ultimate Special Repository|
|OR |At least one of the terms must be included|Ultimate OR Repository finds e.g. Ultimate Repository, Ultimate User, Special Repository|
|NOT |Following term may not be included, "!" may be used alternatively|Ultimate NOT Repository finds e.g. Ultimate user, excludes e.g. Ultimate Repository|
| |Excludes following term from search|Ultimate Repository -Special finds e.g. Ultimate Repository, excludes e.g. Ultimate Special Repository|
|+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |Following term must be included|Ultimate +Repository finds e.g. my Repository, Ultimate Repository|
## Grouping

View File

@@ -98,6 +98,16 @@ describe("tests for getQueryStringFromLocation", () => {
expect(getQueryStringFromLocation(location)).toBe("abc");
});
it("should return the query string with a space instead of a plus symbol", () => {
const location = createLocation("?q=+(Test)");
expect(getQueryStringFromLocation(location)).toBe(" (Test)");
});
it("should return the query string with a plus symbol", () => {
const location = createLocation("?q=%2B(Test)");
expect(getQueryStringFromLocation(location)).toBe("+(Test)");
});
it("should return query string from multiple parameters", () => {
const location = createLocation("?x=a&y=b&q=abc&z=c");
expect(getQueryStringFromLocation(location)).toBe("abc");