tpmjs/packages/tools/official/url-normalize
Ajax Davis 09fd0a5833 feat: add 55 new business tools and improve existing implementations
New tools added across multiple domains:
- Sales: lead-score, proposal-outline, objection-response
- Marketing: competitor-brief, campaign-brief, social-post-draft, email-subject-score, audience-persona, content-calendar-plan, pricing-page-copy
- HR: job-description-draft, interview-questions, performance-review-draft, onboarding-checklist, compensation-band, survey-analyze, org-chart-format, offer-letter-draft, exit-interview-summarize, policy-doc-format
- Legal: contract-clause-scan, nda-template-draft, tos-readability, risk-clause-highlight, invoice-terms-extract, gdpr-data-map, copyright-notice, trademark-check
- Finance: expense-categorize, invoice-data-extract, budget-variance, cash-flow-project, revenue-breakdown, ratio-analysis, tax-deduction-scan, reconciliation-match
- Customer Experience: feedback-themes, churn-risk-score, nps-analysis, ticket-categorize, response-template-suggest, health-score-calculate, renewal-forecast
- Education: lesson-plan-outline, quiz-generate, rubric-create, syllabus-format, progress-report-draft, learning-objective-write, curriculum-map

Also includes improvements to 68 existing tool implementations.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-01 19:23:32 +10:00
..
src feat: add 55 new business tools and improve existing implementations 2026-01-01 19:23:32 +10:00
CHANGELOG.md chore: version packages 2025-12-31 23:54:47 +10:00
package.json chore: version packages 2025-12-31 23:54:47 +10:00
README.md feat: add 100+ official TPMJS tools 2025-12-31 22:55:56 +10:00
tsconfig.json feat: add 100+ official TPMJS tools 2025-12-31 22:55:56 +10:00
tsup.config.ts feat: add 100+ official TPMJS tools 2025-12-31 22:55:56 +10:00

@tpmjs/tools-url-normalize

Normalize URLs with configurable options for consistent URL handling.

Installation

npm install @tpmjs/tools-url-normalize

Usage

import { urlNormalizeTool } from '@tpmjs/tools-url-normalize';

// Use with AI SDK
const result = await urlNormalizeTool.execute({
  url: 'HTTPS://WWW.Example.COM:443/path/?z=1&a=2#section',
  options: {
    sortParams: true,
    removeHash: true,
    lowercase: true,
    removeTrailingSlash: true,
    removeDefaultPort: true,
    removeWWW: true,
  },
});

console.log(result.normalized);
// 'https://example.com/path?a=2&z=1'

console.log(result.changes);
// [
//   { type: 'lowercase', description: '...', before: 'HTTPS:', after: 'https:' },
//   { type: 'lowercase', description: '...', before: 'WWW.Example.COM', after: 'www.example.com' },
//   { type: 'removeWWW', description: '...', before: 'www.example.com', after: 'example.com' },
//   { type: 'removeDefaultPort', description: '...', before: '443', after: '' },
//   { type: 'sortParams', description: '...', before: '?z=1&a=2', after: '?a=2&z=1' },
//   { type: 'removeHash', description: '...', before: '#section', after: '' },
// ]

Features

  • Lowercase conversion: Converts protocol and hostname to lowercase
  • Trailing slash removal: Removes trailing slashes from pathnames
  • Query parameter sorting: Sorts query parameters alphabetically
  • Hash removal: Optionally removes URL fragments
  • Default port removal: Removes standard ports (80, 443, 21)
  • WWW removal: Optionally removes www subdomain
  • Change tracking: Reports all transformations applied

Parameters

  • url (string, required): The URL to normalize
  • options (object, optional): Normalization options
    • sortParams (boolean, default: true): Sort query parameters alphabetically
    • removeHash (boolean, default: false): Remove URL fragment/hash
    • lowercase (boolean, default: true): Convert protocol and hostname to lowercase
    • removeTrailingSlash (boolean, default: true): Remove trailing slash from pathname
    • removeDefaultPort (boolean, default: true): Remove default ports
    • removeWWW (boolean, default: false): Remove www subdomain

Returns

{
  normalized: string;
  original: string;
  changes: Array<{
    type: string;
    description: string;
    before: string;
    after: string;
  }>;
  metadata: {
    protocol: string;
    hostname: string;
    pathname: string;
    hasQueryParams: boolean;
    hasHash: boolean;
  };
}

Use Cases

  • URL deduplication in web crawlers
  • Canonical URL generation for SEO
  • Link comparison and matching
  • Database indexing of URLs
  • Analytics tracking consistency

Example with AI Agent

import { openai } from '@ai-sdk/openai';
import { generateText } from 'ai';
import { urlNormalizeTool } from '@tpmjs/tools-url-normalize';

const result = await generateText({
  model: openai('gpt-4'),
  tools: {
    urlNormalize: urlNormalizeTool,
  },
  prompt: 'Normalize this URL and remove the hash: https://Example.com/PATH/?b=2&a=1#top',
});

License

MIT