# url — URL Parsing > `import { getUrlParts } from 'puffy-core/url'` > CJS: `const { url: { getUrlParts } } = require('puffy-core')` > Also available in snake_case: `get_url_parts` --- ## getUrlParts Parses a URL string using the native `URL` API and returns all standard URL components plus convenience properties. ### Signature ``` getUrlParts(url: string) → Object ``` ### Return value ```js { href: string, // Full URL origin: string, // protocol + host (e.g., 'https://localhost:3456') protocol: string, // 'https:', 'http:', etc. username: string, // URL-embedded username ('' if none) password: string, // URL-embedded password ('' if none) host: string, // hostname:port (e.g., 'localhost:3456') hostname: string, // Domain only (e.g., 'localhost') port: string, // Port number as string ('' if default) pathname: string, // Path (e.g., '/hello/world') search: string, // Query string with '?' (e.g., '?name=carl&age=40') searchParams: URLSearchParams, // Native URLSearchParams object queryParams: { [key]: string }, // Query params as plain object hash: string, // Fragment with '#' (e.g., '#home') ext: string|null // File extension from pathname (e.g., '.html', '.jpg') } ``` ### Example ```js getUrlParts('https://localhost:3456/hello/world.html?name=carl&age=40#home') // { // href: 'https://localhost:3456/hello/world.html?name=carl&age=40#home', // origin: 'https://localhost:3456', // protocol: 'https:', // username: '', // password: '', // host: 'localhost:3456', // hostname: 'localhost', // port: '3456', // pathname: '/hello/world.html', // search: '?name=carl&age=40', // searchParams: URLSearchParams { 'name' => 'carl', 'age' => '40' }, // queryParams: { name: 'carl', age: '40' }, // hash: '#home', // ext: '.html' // } ``` ### Example — URL without extension ```js getUrlParts('https://api.example.com/users?page=2') // { // ... // pathname: '/users', // ext: null, ← no file extension // queryParams: { page: '2' } ← values are always strings // } ``` GOTCHA: `queryParams` values are always strings. If you need numbers, convert them yourself: `Number(parts.queryParams.page)`. GOTCHA: `ext` only detects extensions in the pathname. Query strings and hash fragments are not considered.