context("URL")
test_that("Query string parsing", {
expect_identical(
parseQueryString("?foo=1&bar=b+a%20r&b+a%20z=baz&=nokey&novalue=&=&noequal&end=end"),
list(
foo = '1',
bar = 'b a r',
`b a z` = 'baz',
'nokey',
novalue = '',
'',
noequal = '',
end = 'end'
)
)
# Should be the same with or without leading question mark
expect_identical(parseQueryString("?foo=1&bar=b"), parseQueryString("foo=1&bar=b"))
# Nested and non-nested query strings
expect_identical(
parseQueryString("a[i1][j1]=x&b[i1][j1]=y&b[i2][j1]=z"),
list(
"a[i1][j1]" = "x",
"b[i1][j1]" = "y",
"b[i2][j1]" = "z"
)
)
expect_identical(
parseQueryString("a[i1][j1]=x&b[i1][j1]=y&b[i2][j1]=z", nested = TRUE),
list(
a = list(i1 = list(j1 = "x")),
b = list(
i1 = list(j1 = "y"),
i2 = list(j1 = "z")
)
)
)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.