mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-22 14:45:20 +00:00
Merge pull request #55 from LemmyNet/urlencode-search
Use urlencode for search queries (fixes #10)
This commit is contained in:
commit
28a474234f
|
@ -137,8 +137,9 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
|
||||||
if (searchParam === '') {
|
if (searchParam === '') {
|
||||||
this.context.router.history.push(`/search/`);
|
this.context.router.history.push(`/search/`);
|
||||||
} else {
|
} else {
|
||||||
|
const searchParamEncoded = encodeURIComponent(searchParam);
|
||||||
this.context.router.history.push(
|
this.context.router.history.push(
|
||||||
`/search/q/${searchParam}/type/All/sort/TopAll/page/1`
|
`/search/q/${searchParamEncoded}/type/All/sort/TopAll/page/1`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ export class Search extends Component<any, SearchState> {
|
||||||
};
|
};
|
||||||
|
|
||||||
static getSearchQueryFromProps(q: string): string {
|
static getSearchQueryFromProps(q: string): string {
|
||||||
return q || '';
|
return decodeURIComponent(q) || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
static getSearchTypeFromProps(type_: string): SearchType {
|
static getSearchTypeFromProps(type_: string): SearchType {
|
||||||
|
@ -504,11 +504,12 @@ export class Search extends Component<any, SearchState> {
|
||||||
|
|
||||||
updateUrl(paramUpdates: UrlParams) {
|
updateUrl(paramUpdates: UrlParams) {
|
||||||
const qStr = paramUpdates.q || this.state.q;
|
const qStr = paramUpdates.q || this.state.q;
|
||||||
|
const qStrEncoded = encodeURIComponent(qStr);
|
||||||
const typeStr = paramUpdates.type_ || this.state.type_;
|
const typeStr = paramUpdates.type_ || this.state.type_;
|
||||||
const sortStr = paramUpdates.sort || this.state.sort;
|
const sortStr = paramUpdates.sort || this.state.sort;
|
||||||
const page = paramUpdates.page || this.state.page;
|
const page = paramUpdates.page || this.state.page;
|
||||||
this.props.history.push(
|
this.props.history.push(
|
||||||
`/search/q/${qStr}/type/${typeStr}/sort/${sortStr}/page/${page}`
|
`/search/q/${qStrEncoded}/type/${typeStr}/sort/${sortStr}/page/${page}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue