Skip to content

ip-addressvsurl

MIT 32 1 522
50.6 million (month) May 05 2015 9.0.5(9 months ago)
101 1 - MIT
Apr 15 2018 49 (month) v2.1.1(5 months ago)

The "ip-address" library is a Node.js library that provides utility functions for working with IP addresses, similar to "ip" library. It provides functions for parsing, validating, and converting IP addresses between different formats, both IPv4 and IPv6.

url is a package for working, modifying and parsing web URLs. This package is for you when PHP's parse_url() is not enough.

Key Features:

  • Parse a URL and access or modify all its components separately.
  • Resolve any relative reference you may find in an HTML document to an absolute URL, based on the document's URL.
  • Get not only the full host of a URL, but also the registrable domain, the domain suffix and the subdomain parts of the host separately (Thanks to the Mozilla Public Suffix List).
  • An advanced API to access and manipulate the URL query component.
  • Compare URLs or components of URLs (e.g. checking if different URLs point to the same host or domain)
  • Thanks to symfony/polyfill-intl-idn it's also no problem to parse internationalized domain names (IDN).
  • Includes an adapter class which implements the PSR-7 UriInterface.

Example Use


const IPAddress = require("ip-address").Address;

// slice and manipulate addresses:
const ipv4 = new IPAddress("192.168.1.1");
console.log(ipv4.addressMinusSuffix); // '192.168.1'

// validate addresses:
console.log(IPAddress.isValid("192.168.1.1")); // true
console.log(IPAddress.isValid("2001:0db8:85a3:0000:0000:8a2e:0370:7334")); // true
<?php
use Crwlr\Url;

$url = new Url('https://www.example.com/path?query=value#fragment');

// Parse url for parts:
echo $url->scheme();
echo $url->host();
echo $url->path();
echo $url->query();
echo $url->fragment();
// update values
echo $url->path("some/new/query");


// Create url from parts:
$url = new Url();
$url->scheme('https');
$url->host('www.example.com');
$url->path('/path');
$url->query('query=value');
$url->fragment('fragment');
echo $url->toString();

Alternatives / Similar


Was this page helpful?