Node.js API compatibility - Url
Explore the integration and usage of the Node.js URL module within the Azion Runtime. The URL module provides utilities to parse and format URLs, manage query strings, and ensure correct URL manipulation.
The url module in Node.js provides utilities for URL resolution and parsing. It allows developers to work with URLs in a structured way, making it easier to manipulate and extract information from them. This module is essential for web applications that need to handle URLs for routing, API requests, and more. It’s available in the Azion Runtime through Node.js compatibility, so functions can parse the incoming request URL, read query parameters, and build new URLs when proxying or redirecting traffic.
Example: URL parsing and formatting
The example below shows how to use the url module in a function:
Example: Request URL parsing
Parse incoming request URLs to extract routing information:
Example: Building URLs dynamically
Construct URLs for API calls and redirects:
Example: URLSearchParams manipulation
Work with query string parameters efficiently:
Example: URL validation and normalization
Validate and normalize user-provided URLs:
Example: URL routing and path matching
Use URL parsing for request routing:
Supported APIs
| API | Status |
|---|---|
URL (global) | 🟢 Supported |
URLSearchParams | 🟢 Supported |
url.URL | 🟢 Supported |
url.URLSearchParams | 🟢 Supported |
url.format() | 🟢 Supported |
url.parse() | 🟡 Deprecated (use new URL()) |
url.resolve() | 🟡 Deprecated (use new URL(relative, base)) |
url.domainToASCII() | 🟡 Partially supported |
url.domainToUnicode() | 🟡 Partially supported |
url.fileURLToPath() | 🟡 Partially supported |
url.pathToFileURL() | 🟡 Partially supported |
url.urlToHttpOptions() | 🟡 Partially supported |