strings.extract_url_path

Supported in:
strings.extract_url_path(url_string)

Description

Extracts the path behind the domain in a URL but before the parameters.

Param data types

STRING

Return type

STRING

Code samples

Example 1

This example shows that nothing is returned when you enter an empty string.

strings.extract_url_path("") = ""
Example 2

This example shows the path that is returned when you provide a valid URL.

strings.extract_url_path("https://developer.test_company.org/en-US/docs/Web/API/URL/pathname?q=value") = "/en-US/docs/Web/API/URL/pathname"
Example 3

This example shows that nothing is returned when you provide a random string that isn't a URL.

strings.extract_url_path("1234") = ""
Example 4

This example shows support for non ASCII characters in a URL.

strings.extract_url_path("http://例子/卷筒纸/中国") = "/卷筒纸/中国"
Example 5

This example shows that an empty string is returned when a URI is provided.

strings.extract_url_path("mailto:?to=&subject=&body=") = ""
Example 6

This example shows the path that is returned when you provide multiple characters before a URL.

strings.extract_url_path("     \t   !$5*^)&dahgsdfs;http://www.google.com/foo/bar") = "/foo/bar"
Example 7

This example shows that an empty string is returned when you provide special characters (for example, #) in a URL.

strings.extract_url_path("test#@google.com") = ""