move urlSearchParamsToObject and global.d.ts to react-sdk

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski
2020-04-13 21:23:40 +01:00
parent c044e1a00c
commit 6764c7e779
3 changed files with 5 additions and 18 deletions

View File

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