Aerostack
search

web-url-parse Edge Function — Web Search

Web Search

Parse a URL into structured parts including protocol, host, pathname, query object, and hash.

navin @navin verified
Updated Mar 12, 2026
GitHub

Edge function web-url-parse Parse a URL into structured parts including protocol, host, pathname, query object, and hash.. Deployed on Cloudflare Workers — zero cold starts, globally distributed. Mount it via your Aerostack workspace to call it from any AI agent.

terminal — aerostack cli
$ npx aerostack add navin/web-url-parse
smart_toy

Use with AI Assistants

MCP

Connect Claude, Cursor, or any MCP-compatible client — then call this function by slug

① Add MCP Server

Add this once — access all Aerostack functions from your AI tool.

claude_desktop_config.json
{
  "mcpServers": {
    "aerostack": {
      "url": "https://mcp.aerostack.dev",
      "type": "http"
    }
  }
}

② Call this function

Ask your AI to use the call_function tool with this slug:

call_function
call_function({
  slug: "web-url-parse",
  args: {
    "url": "example_url"
  }
})

web-url-parse — Parse a URL into structured parts

Decompose any URL into protocol, host, pathname, query params, hash, and more. Supports repeated query keys as arrays.


API

POST /api/web-url-parse

Request body

Field Type Required Description
url string Yes The URL string to parse

Success response (200)

{
  "success": true,
  "data": {
    "protocol": "https",
    "host": "example.com",
    "hostname": "example.com",
    "port": null,
    "pathname": "/path",
    "search": "?foo=bar",
    "hash": "#section",
    "origin": "https://example.com",
    "query": { "foo": "bar" },
    "valid": true
  }
}

Error responses

Code HTTP When
INVALID_INPUT 400 Missing url field
INTERNAL_ERROR 500 Unexpected error

Usage

cURL
curl -X POST "$FUNCTION_URL" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/path?tag=a&tag=b#section"}'
TypeScript / JavaScript
const response = await fetch(FUNCTION_URL, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ url: 'https://example.com/path?foo=bar' }),
});
const { data } = await response.json();
console.log(data.query); // { foo: 'bar' }
Direct import
import { webUrlParse } from '@aerostack/functions/web-url-parse';

const result = webUrlParse({ url: 'https://example.com?tag=a&tag=b' });
console.log(result.query); // { tag: ['a', 'b'] }

Use Cases

  • Extracting UTM parameters from marketing URLs for analytics
  • Validating and normalizing incoming redirect URLs
  • Building URL-aware routing logic in edge middleware

Metadata

upgrade Version 1.0.0
gavel License MIT
language Language typescript
cloud Provider aerostack

Tags

web
deployed_code

Build and publish your own functions

Write a TypeScript function, deploy it to the edge, and share it with thousands of developers — in minutes.

More Web Search Functions

Browse Web Search Functions →

Frequently asked questions

What does the web-url-parse function do? +

web-url-parse is a serverless edge function for web-search automation written in aerostack. Deploy it to Cloudflare Workers via your Aerostack workspace.

How do I deploy the web-url-parse function? +

Install the Aerostack CLI and run: ```bash aerostack deploy function @navin/web-url-parse ``` It will be live on Cloudflare Workers in seconds.

What runtime does web-url-parse use? +

web-url-parse runs on aerostack on the Cloudflare Workers edge runtime — zero cold starts, globally distributed.

Can I customise the web-url-parse function? +

Yes. Fork the function from your Aerostack dashboard, modify the source, and redeploy. All changes are version-controlled.