mirror of
https://github.com/nushell/nushell
synced 2024-11-16 09:47:57 +00:00
92c4097f8d
# Description Refactor command: "to url" in: "to url query". Changed usage sentence. Closes: #7495 # User-Facing Changes Now we get a query string from a record or table by using command: "to url query". ``` > help to url query Convert record or table into query string applying percent-encoding. Usage: > to url query Flags: -h, --help - Display the help message for this command Signatures: <record> | to url query -> <string> <table> | to url query -> <string> Examples: Outputs a query string representing the contents of this record > { mode:normal userid:31415 } | to url query Outputs a query string representing the contents of this 1-row table > [[foo bar]; ["1" "2"]] | to url query Outputs a query string representing the contents of this record > {a:"AT&T", b: "AT T"} | to url query ``` # Tests + Formatting Added this test: ``` Example { description: "Outputs a query string representing the contents of this record", example: r#"{a:"AT&T", b: "AT T"} | to url query"#, result: Some(Value::test_string("a=AT%26T&b=AT+T")), }, ``` to ensure percent-encoding. # After Submitting If PR is accepted I'll open another PR on documentation to notify changes on [this.](https://github.com/nushell/nushell.github.io/blob/main/book/commands/to_url.md)
16 lines
360 B
Rust
16 lines
360 B
Rust
use nu_test_support::{nu, pipeline};
|
|
|
|
#[test]
|
|
fn can_encode_and_decode_urlencoding() {
|
|
let actual = nu!(
|
|
cwd: "tests/fixtures/formats", pipeline(
|
|
r#"
|
|
open sample.url
|
|
| url build-query
|
|
| from url
|
|
| get cheese
|
|
"#
|
|
));
|
|
|
|
assert_eq!(actual.out, "comté");
|
|
}
|