Nushell
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
  • Categories

    • Bits
    • Bytes
    • Chart
    • Conversions
    • Core
    • Database
    • Dataframe
    • Dataframe Or Lazyframe
    • Date
    • Debug
    • Default
    • Env
    • Experimental
    • Expression
    • Filesystem
    • Filters
    • Formats
    • Generators
    • Hash
    • History
    • Lazyframe
    • Math
    • Misc
    • Network
    • Path
    • Platform
    • Plugin
    • Prompt
    • Random
    • Removed
    • Shells
    • Strings
    • System
    • Viewers

url encode for strings

Converts a string to a percent encoded web safe string.

Signature

> url encode {flags} ...rest

Flags

  • --all, -a: encode all non-alphanumeric chars including /, ., :

Parameters

  • ...rest: For a data structure input, check strings at the given cell paths, and replace with result.

Input/output types:

inputoutput
stringstring
list<string>list<string>
tabletable
recordrecord

Examples

Encode a url with escape characters

> 'https://example.com/foo bar' | url encode
https://example.com/foo%20bar

Encode multiple urls with escape characters in list

> ['https://example.com/foo bar' 'https://example.com/a>b' '中文字/eng/12 34'] | url encode
╭───┬─────────────────────────────────────────╮
│ 0 │ https://example.com/foo%20bar           │
│ 1 │ https://example.com/a%3Eb               │
│ 2 │ %E4%B8%AD%E6%96%87%E5%AD%97/eng/12%2034 │
╰───┴─────────────────────────────────────────╯

Encode all non alphanumeric chars with all flag

> 'https://example.com/foo bar' | url encode --all
https%3A%2F%2Fexample%2Ecom%2Ffoo%20bar