Skip to content

Instantly share code, notes, and snippets.

@cattaka
Last active November 29, 2018 08:52
Show Gist options
  • Save cattaka/476258cd766e122f6060c47b70a4ef64 to your computer and use it in GitHub Desktop.
Save cattaka/476258cd766e122f6060c47b70a4ef64 to your computer and use it in GitHub Desktop.
CREATE TEMPORARY FUNCTION pullFromQueryParams(s string, key string)
RETURNS string
LANGUAGE js AS """
// function pullFromQueryParams(s, key) {
if (!s) return null;
var ts = s.split("&");
for (var i = 0;i<ts.length;i++) {
var vs = ts[i].split("=",2);
if (vs[0] == key && vs.length >= 2) {
return decodeURIComponent(vs[1]);
}
}
return null;
// }
""";
CREATE TEMPORARY FUNCTION pullKeysFromQueryParams(s string)
RETURNS array<string>
LANGUAGE js AS """
// function pullKeysFromQueryParams(s) {
var results = [];
if (s) {
var ts = s.split("&");
for (var i = 0;i<ts.length;i++) {
var vs = ts[i].split("=",2);
results.push(vs[0]);
}
}
return results;
// }
""";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment