Code Monkey home page Code Monkey logo

url's Introduction

crwlr.software logo

A Swiss Army knife for 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.

Documentation

You can find the documentation at crwlr.software.

Contributing

If you consider contributing something to this package, read the contribution guide (CONTRIBUTING.md).

url's People

Contributors

enricodias avatar nuernbergera avatar otsch avatar ravage84 avatar szepeviktor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

url's Issues

Don't use parse_str to parse query string to array

Converting a query string to array uses PHP's parse_str() function, but this function seems to be a little outdated. Because dots and spaces aren't allowed in PHP variables it replaces all of them in keys and values to underscores. This behavior should only be necessary when you want to parse a query string to separate variables, which is obviously not a good practice and is a deprecated use of this function since PHP 7.2.0 (http://php.net/manual/en/function.parse-str.php#refsect1-function.parse-str-changelog).

So a workaround for this should be implemented because it can lead to wrong keys or values when using the queryArray method of the Url class.

Allow psr/http-message v2

Hi!

I just tried to install this package in a fresh Laravel application, but was greeted by the message that it could not satisfy my composer lock file, as the psr/http-message package was locked at v2 and this package only allows v1.

When I look at the release notes, it should be fine to include v2 as well. Other packages seem to support both v1 and v2 at the same time.
Scherm­afbeelding 2023-06-28 om 14 27 52

I can lock the psr/http-message to v1 in my project, but I think it will be better to follow the latest releases.

Would be great if this is possible.

Error when parsing an url with an umlaut

When I parse an URL that contains an umlaut I get an InvalidUrlException.

Steps to reproduce:

  1. Call Url::parse('https://www.example.com/bürokaufmann')

Error message:
https://www.example.com/bürokaufmann is not a valid url.

Add the queryParam() method

It is often necessary to update just one parameter in a query, for example:

        $url = new Url($link);
        $params = $url->queryArray();
        $params['foo'] = 'bar';
        $url->queryArray($params);

It would be great to do this in one call:

        $url = new Url($link);
        $url->queryParam('foo', 'bar');

And also the getter:

        $url = new Url($link);
        $url->queryParam('foo', 'bar');

And also for removal:

        $url = new Url($link);
        $url->queryParam('foo', null);
        // or
        $url->removeQueryParam('foo');

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.