mirror of
https://github.com/nushell/nushell.git
synced 2024-11-30 04:14:17 +01:00
a03c1c266c
Implemented URL decoding as a url subcommand, created corresponding unit tests. The logic, examples and descriptions were based on the existing `url encode` command. Resolves #10563 # Description Added a new `url decode` command to compliment the existing `url encode`, as proposed by myself in #10563. It takes a string, list of strings or cell path and produces the corresponding decoded strings. ![image](https://github.com/nushell/nushell/assets/4030336/815a34e9-7ceb-4d09-9d74-e700ba513b17) # User-Facing Changes New url subcommand `url decode`, as described above. # Tests + Formatting I've added unit tests for the new subcommand and ensured all actions outlined below showed no issues. - [x] `cargo fmt --all -- --check` - [x] `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` - [x] `cargo test --workspace` - [x] `cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"`
20 lines
503 B
Rust
20 lines
503 B
Rust
use nu_test_support::nu;
|
|
|
|
#[test]
|
|
fn url_decode_simple() {
|
|
let actual = nu!(r#"'a%20b' | url decode"#);
|
|
assert_eq!(actual.out, "a b");
|
|
}
|
|
|
|
#[test]
|
|
fn url_decode_special_characters() {
|
|
let actual = nu!(r#"'%21%40%23%24%25%C2%A8%26%2A%2D%2B%3B%2C%7B%7D%5B%5D%28%29' | url decode"#);
|
|
assert_eq!(actual.out, r#"!@#$%¨&*-+;,{}[]()"#);
|
|
}
|
|
|
|
#[test]
|
|
fn url_decode_error_invalid_utf8() {
|
|
let actual = nu!(r#"'%99' | url decode"#);
|
|
assert!(actual.err.contains("invalid utf-8 sequence"));
|
|
}
|