From 42572790262d2752041a3659725e119a9ba74925 Mon Sep 17 00:00:00 2001 From: Alexander Rose <alex.rose@rcsb.org> Date: Tue, 28 Aug 2018 19:49:41 -0700 Subject: [PATCH] added urlQueryParameter helper function --- src/mol-util/url-query.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/mol-util/url-query.ts diff --git a/src/mol-util/url-query.ts b/src/mol-util/url-query.ts new file mode 100644 index 000000000..a4a10a837 --- /dev/null +++ b/src/mol-util/url-query.ts @@ -0,0 +1,12 @@ +/** + * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. + * + * @author Alexander Rose <alexander.rose@weirdbyte.de> + */ + +export function urlQueryParameter (id: string) { + if (typeof window === 'undefined') return undefined + const a = new RegExp(`${id}=([^&#=]*)`) + const m = a.exec(window.location.search) + return m ? decodeURIComponent(m[1]) : undefined +} \ No newline at end of file -- GitLab