forked from matrix/element-web
move urlSearchParamsToObject and global.d.ts to react-sdk
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
c044e1a00c
commit
6764c7e779
|
@ -97,7 +97,6 @@
|
|||
"@babel/register": "^7.7.4",
|
||||
"@babel/runtime": "^7.7.6",
|
||||
"@types/jest": "^25.2.1",
|
||||
"@types/modernizr": "^3.5.3",
|
||||
"@types/react": "16.9",
|
||||
"@types/react-dom": "^16.9.4",
|
||||
"autoprefixer": "^9.7.3",
|
||||
|
|
|
@ -14,25 +14,15 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import "modernizr";
|
||||
import "matrix-react-sdk/src/@types/global";
|
||||
import {Renderer} from "react-dom";
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
Modernizr: ModernizrAPI & FeatureDetects;
|
||||
Olm: {
|
||||
init: () => Promise<void>;
|
||||
};
|
||||
|
||||
mxSendRageshake: (text: string, withLogs?: boolean) => void;
|
||||
matrixChat: ReturnType<Renderer>;
|
||||
|
||||
// electron-only
|
||||
ipcRenderer: any;
|
||||
}
|
||||
|
||||
// workaround for https://github.com/microsoft/TypeScript/issues/30933
|
||||
interface ObjectConstructor {
|
||||
fromEntries?(xs: [string|number|symbol, any][]): object
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue