use js-sdk decodeParams utility

This commit is contained in:
Michael Telatynski 2021-07-16 13:10:58 +01:00
parent b03b4582c0
commit 75e4d16462

View File

@ -14,11 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import {urlSearchParamsToObject} from "matrix-react-sdk/src/utils/UrlUtils"; import { QueryDict, decodeParams } from "matrix-js-sdk/src/utils";
interface IParamsObject {
[key: string]: string;
}
// We want to support some name / value pairs in the fragment // We want to support some name / value pairs in the fragment
// so we're re-using query string like format // so we're re-using query string like format
@ -36,15 +32,15 @@ export function parseQsFromFragment(location: Location) {
const result = { const result = {
location: decodeURIComponent(hashparts[0]), location: decodeURIComponent(hashparts[0]),
params: <IParamsObject>{}, params: <QueryDict>{},
}; };
if (hashparts.length > 1) { if (hashparts.length > 1) {
result.params = urlSearchParamsToObject<IParamsObject>(new URLSearchParams(hashparts[1])); result.params = decodeParams(hashparts[1]);
} }
return result; return result;
} }
export function parseQs(location: Location) { export function parseQs(location: Location): QueryDict {
return urlSearchParamsToObject<IParamsObject>(new URLSearchParams(location.search)); return decodeParams(location.search.substring(1));
} }