Giter Club home page Giter Club logo

purl's People

Contributors

acidvertigo avatar arnaud-lb avatar atijust avatar b-alidra avatar cosmologist avatar deminy avatar dmyers avatar jeremykendall avatar jeroendedauw avatar jwage avatar kbond avatar longchiwen avatar mmcev106 avatar nyholm avatar paulredmond avatar pborreli avatar peter279k avatar rcmachado avatar royopa avatar scrutinizer-auto-fixer avatar seldaek 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  avatar  avatar  avatar  avatar

Watchers

 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

purl's Issues

How to remove a part of the url ?

to remove host from the url

$url->set('host', null) or $url->remove('host')

if i do $url->set('host', null) and $url->getUrl() gives me something like ://google.com. The "http" alone is gone.
and if set the host to 'http' to //google.com url, it gives http://://google.com

Changing only the domain part?

A client has a website with different URLs depending on the locale. Is there a way to change the domain part without losing the subdomain part?

<?php

$englishUrl = new \Purl\Url('http://app.englishdomain.com/page/1');

$frenchUrl = clone($englishUrl);
$frenchUrl->set('host', 'frenchdomain.com');

echo $frenchUrl;
// I expect http://app.frenchdomain.com/page/1
// But I get http://frenchdomain.com/page/1

echo $frenchUrl->registerableDomain;
// I expect frenchdomain.com
// But I get englishdomain.com

// Ok ... maybe using ->set('registerableDomain') ?
$frenchUrl = clone($englishUrl);
$frenchUrl->set('registerableDomain', 'frenchdomain.com');

echo $frenchUrl->registerableDomain;
// Yay! I get frenchdomain.com

echo $frenchUrl;
// Dammit, I get http://app.englishdomain.com/page/1

// Hey, maybe I can build it piece by piece...right?
$frenchUrl = \Purl\Url::parse('http://frenchdomain.com')
    ->set('subdomain', $englishUrl->subdomain)
    ->setPath($englishUrl->getPath())
    ->set('query', $englishUrl->query);

echo $frenchUrl;
// I get http://frenchdomain.com/page/1
// Where's the subdomain again?

Thanks!

Incorrect handling of long generic domain extensions

Hello,

I think the library is not capable of handling the new and long(er) generic domain extensions, such as .photography, .club, .company, etc.

I think you have a restriction on the max length of the extension set to 3. I've found one here, but I'm not sure if it's the only one. I will take a look in the next days and maybe send a PR:
src/Purl/Url.php:107

Thanks,
J.

Why is the canonical domain reversed?

This is apparently the canonical domain:

com.jwage.domain.sub/index.php?param1=value1

Also I noticed that the README doesn't mention that it also includes the query parameters. It's a bit confusing since it was part of the Domains section.

Would be good to note the new $resource parameter too!

Why does remove() return "void"

Personally I am not a big fan of fluent interfaces, but I do think that in case one uses them, it should be done in a consistent way.

Is there any particular reason that remove() (which is specific to this library) returns void ?

public function remove(string $key) : void

When this is possible:

$url = \Purl\Url::parse('http://jwage.com')
    ->set('scheme', 'https')
    ->set('host', 'jwageMirror.com');

Then this should (?) also be possible?:

$url = \Purl\Url::parse('http://jwage.com')
    ->remove('scheme')
    ->remove('host');

require old jeremykendall/php-domain-parser version

I'm getting the following errors. This is because jwage/purl requires jeremykendall/php-domain-parser "^1.3.1". Could you change to allow a newer version please.

PHP Deprecated: idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated in /var/www/vhosts/rubus.pineberry.com/vendor/jeremykendall/php-domain-parser/library/Pdp/Parser.php on line 209

PHP Deprecated: idn_to_utf8(): INTL_IDNA_VARIANT_2003 is deprecated in /var/www/vhosts/rubus.pineberry.com/vendor/jeremykendall/php-domain-parser/library/Pdp/Parser.php on line 192

Problem with no schema urls. Not the same as the other issue.

When you parse a url like: blahblah.com.

It creates url like: :///blahblah.com.

The problem with this, is that even if you set the protocol, you end up with:

http:///blahblah.com.

This is because the Url::httpBuildUrl adds a / even when there is not $data['user'], $data['host'] or $data['port'].

This results in 3 slashes because it thinks blahblah.com is the path and not the host.

Incompatible with modern software

Any software package with a dev dependency on PhpUnit 7+ is incompatible with jwage/purl:

jwage/purl dev-master requires phpunit/phpunit ^4.8|^5.5|^6.5

Conflicts with:

Installation request for phpunit/phpunit ~7.0

The problem is probably caused by phpunit being in require rather than require -dev.

Feature request: building relative urls

Library should be able to create relative urls:

$url = new \Purl\Url('/events');
$url->query->set('param1', 'value1');
echo $url->getUrl();

Expected output should be:

/events?param1=value1

Purl cannot parse some Blogspot sudomains.

Hi,

While those work fine:

http://anil.blogspot.com.tr :: $purl->subdomain is "anil"
http://anil.blogspot.com :: $purl->subdomain is "anil"

Those domain extensions doesn't work:

http://anil.blogspot.co.uk :: $purl->subdomain is NULL
http://anil.blogspot.nl :: $purl->subdomain is NULL
http://anil.blogspot.in :: $purl->subdomain is NULL

Could be a bug.

Is there any way I can extend domain extensions list for Blogspot and allow those domain extensions too?

Using parse() inside loop eats up all memory

I have a loop that runs around 75 times before all the memory on my system is allocated. Each loop purl consumes around 1.5mb by including the public suffix list. Is there a way around this?

function convert($size)
{
    $unit=array('b','kb','mb','gb','tb','pb');
    return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i];
}

foreach ($domains as $domain)
{
    echo \Purl\Url::parse($domain);
    // echo convert(memory_get_usage(true)); 
    // echo '<br />';
}

The memory usage output is below

16 mb
17.75 mb
19.5 mb
21 mb
22.5 mb
24 mb
25.5 mb
27 mb
28.5 mb
30 mb
31.5 mb
33 mb
34.5 mb
36 mb
37.5 mb
39 mb
40.5 mb
42 mb
43.5 mb
45 mb
46.5 mb
48 mb
49.5 mb
51 mb
52.5 mb
54 mb
55.5 mb
57 mb
58.5 mb
60 mb
61.5 mb
63 mb
64.5 mb
66 mb
67.5 mb
69 mb
70.5 mb
72 mb
73.5 mb
75 mb
76.5 mb
78 mb
79.5 mb
81 mb
82.5 mb
84 mb
85.5 mb
87 mb
88.5 mb
90 mb
91.5 mb
93 mb
94.5 mb
96 mb
97.5 mb
99 mb
100.5 mb
102 mb
103.5 mb
105 mb
106.5 mb
106.5 mb
108 mb
109.5 mb
111 mb
112.5 mb
114 mb
115.5 mb
117 mb
118.25 mb
119.75 mb
119.75 mb
121.25 mb
122.75 mb
124.25 mb

Support "protocol relative" (or "scheme less") URLs

Hi,
Does Purl support "protocol relative"/"schemeless" URLs?

About schemeless protocol URIs:
http://www.paulirish.com/2010/the-protocol-relative-url/
http://tools.ietf.org/html/rfc3986#section-4.2

Judging by the Purl::httpBuildUrl() method, I'm not sure it does:
https://github.com/jwage/purl/blob/master/src/Purl/Url.php#L317

The use case for this:
Being able to get any URL instance in a schemeless format, so files can be loaded by either http or https, based on the current browser protocol.

how to set IP address as host in a url ?

if i try to set an IP address as host name it give an InvalidArgument exception.

$url = 'http://www.google.com';
$url = new Url($url);
$url->set('host', '8.8.8.8');

now $url->getUrl() results in InvalidArgumentException

Purl can fail to parse the fragment

Purl tries to parse fragments, but does not check for errors. When it happens, the fragment is completely missing from the stringified URL:

$url = new Url('http://example.com/#hello:123');
echo (string) $url, "\n";

This script outputs this:

http://example.com/

The problem is that in Fragment.php, $this->data is merged with the result of parse_url($this->fragment). If parse_url returns false, array_merge returns null, and $this->data is null:

$this->data = array_merge($this->data, parse_url($this->fragment));

Problem with parsing a URL contains # before the query string

I have this Url 'http://www.myurl.com/#!/any_path/?param1=val1' and I want to add a new query parameter to it, so I did that:

        $url = new \Purl\Url('http://www.myurl.com/#!/any_path/?param1=val1');
        $url->getQuery()->set('param2', 'val2');
        echo $url->getUrl(); //http://www.myurl.com/?param2=val2#!/any_path/?param1=val1

I'm expecting this url 'http://www.myurl.com/#!/any_path/?param1=val1&param2=val2' as an output not 'http://www.myurl.com/?param2=val2#!/any_path/?param1=val1'

Any Idea!

Composer.json points at wrong version of php-domain-parser.

Hello,

I had to change the composer.json.

    "require": {
        "php": ">=5.3.0",
        "jeremykendall/php-domain-parser": "1.*"
    } 

to

    "require": {
        "php": ">=5.3.0",
        "jeremykendall/php-domain-parser": "1.1.0"
    } 

To install this.
Version 1.2.0 does not seem to be compatible and the wildcard auto points at that one.

Domain 'localhost' is stripped from input URL

Test case:

<?php

require_once __DIR__ . "/vendor/autoload.php";

$url = new \Purl\Url('http://localhost/');
echo $url . "\n";

Expected output:

http://localhost/

Actual output:

http:///

This is using version 0.0.3.

Support PHP8

At this time composer refuses to allow this package to be installed alongside PHP 8.

8.0 does not satisfy constraint ^7.2

Joining with a protocol-relative url

Many sites now use protocol-relative urls (starting with //) to link to dependencies, but joining these in Purl seems to ignore the given scheme.

For example:

$url = new \Purl\Url('https://example.com');
echo $url->scheme . PHP_EOL; // https
$url->join('//code.jquery.com/jquery-3.1.0.js');
echo $url->scheme . PHP_EOL; // http
echo $url->getUrl(); // http://code.jquery.com/jquery-3.1.0.js

The page at https://example.com references jQuery using a protocol-relative url (//code.jquery.com/). Browsers would request this using the scheme of the parent page - in this case https, but Purl joins it as http.

Nz domains are not parsing correctly

I am using version 0.0.7 and tested this upto 0.0.9

$url = \Purl\Url::parse('https://naren.nz/');
echo $url->registerableDomain;
//produces null
//expected naren.nz
$url = \Purl\Url::parse('https://www.naren.nz/');
echo $url->registerableDomain;
//produces "www.naren.nz"
//expected naren.nz

Please let me know if you need additional information.

Add support for longer TLDs

Please add support for longer TLDs. Currently, only two- and tree-letter TLDs are supported (such as .org, .cz, .de) but there are longer TLDs (e.g. .info, .name, .museum and so on) this time and many more ones will be confirmed by ICANN in the near future.

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.