Skip to content

Commit

Permalink
Merge pull request #26 from crwlrsoft/v1.1
Browse files Browse the repository at this point in the history
Fix issue in Resolver
  • Loading branch information
otsch authored Feb 12, 2022
2 parents 2b55fe1 + fcebba1 commit ba7b44f
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 7 deletions.
5 changes: 3 additions & 2 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@

return $config->setFinder($finder)
->setRules([
'@PSR2' => true,
'@PSR12' => true,
'strict_param' => true,
'single_class_element_per_statement' => false,
'array_syntax' => ['syntax' => 'short'],
'blank_line_after_opening_tag' => false,
])
->setRiskyAllowed(true)
->setUsingCache(true);
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.1.1] - 2022-01-12
### Fixed
- Resolving relative paths without leading slash against a
base url with an empty path.

### Changed
- Update schemes and suffixes lists.

## [1.1.0] - 2021-01-10
### Added
- Static method to create PSR-7 Uri object
Expand Down
5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ guarantee that your feature will be merged.
### Coding Style

This package follows the
[PSR-2](https://www.php-fig.org/psr/psr-2/) coding standard.
[PSR-12](https://www.php-fig.org/psr/psr-12/) coding standard.
Linting can be executed using the `composer cs` command.

### Branching
Expand All @@ -40,12 +40,13 @@ please send your pull request to the branch of the latest version
affected by the issue. If you're developing a new feature, branch
out from the master branch.

### Tests and linting
### Code quality tools

When you're making changes to this package please always run
tests and linting. Commands:
`composer test`
`composer cs`
`composer stan`

Ideally you add the pre-commit git hook that is shipped with
this repo that will run tests and linting. Add it to your local
Expand Down
2 changes: 1 addition & 1 deletion data/schemes.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return ['aaa'=>0,'aaas'=>0,'about'=>0,'acap'=>0,'acct'=>0,'acd'=>0,'acr'=>0,'adiumxtra'=>0,'adt'=>0,'afp'=>0,'afs'=>0,'aim'=>0,'amss'=>0,'android'=>0,'appdata'=>0,'apt'=>0,'ar'=>0,'ark'=>0,'attachment'=>0,'aw'=>0,'barion'=>0,'beshare'=>0,'bitcoin'=>0,'bitcoincash'=>0,'blob'=>0,'bolo'=>0,'browserext'=>0,'cabal'=>0,'calculator'=>0,'callto'=>0,'cap'=>0,'cast'=>0,'casts'=>0,'chrome'=>0,'chrome-extension'=>0,'cid'=>0,'coap'=>0,'coap+tcp'=>0,'coap+ws'=>0,'coaps'=>0,'coaps+tcp'=>0,'coaps+ws'=>0,'com-eventbrite-attendee'=>0,'content'=>0,'content-type'=>0,'crid'=>0,'cvs'=>0,'dab'=>0,'dat'=>0,'data'=>0,'dav'=>0,'diaspora'=>0,'dict'=>0,'did'=>0,'dis'=>0,'dlna-playcontainer'=>0,'dlna-playsingle'=>0,'dns'=>0,'dntp'=>0,'doi'=>0,'dpp'=>0,'drm'=>0,'drop'=>0,'dtmi'=>0,'dtn'=>0,'dvb'=>0,'dvx'=>0,'dweb'=>0,'ed2k'=>0,'elsi'=>0,'embedded'=>0,'ens'=>0,'ethereum'=>0,'example'=>0,'facetime'=>0,'fax'=>0,'feed'=>0,'feedready'=>0,'fido'=>0,'file'=>0,'filesystem'=>0,'finger'=>0,'first-run-pen-experience'=>0,'fish'=>0,'fm'=>0,'ftp'=>0,'fuchsia-pkg'=>0,'geo'=>0,'gg'=>0,'git'=>0,'gizmoproject'=>0,'go'=>0,'gopher'=>0,'graph'=>0,'gtalk'=>0,'h323'=>0,'ham'=>0,'hcap'=>0,'hcp'=>0,'http'=>0,'https'=>0,'hxxp'=>0,'hxxps'=>0,'hydrazone'=>0,'hyper'=>0,'iax'=>0,'icap'=>0,'icon'=>0,'im'=>0,'imap'=>0,'info'=>0,'iotdisco'=>0,'ipfs'=>0,'ipn'=>0,'ipns'=>0,'ipp'=>0,'ipps'=>0,'irc'=>0,'irc6'=>0,'ircs'=>0,'iris'=>0,'iris.beep'=>0,'iris.lwz'=>0,'iris.xpc'=>0,'iris.xpcs'=>0,'isostore'=>0,'itms'=>0,'jabber'=>0,'jar'=>0,'jms'=>0,'keyparc'=>0,'lastfm'=>0,'lbry'=>0,'ldap'=>0,'ldaps'=>0,'leaptofrogans'=>0,'lorawan'=>0,'lvlt'=>0,'magnet'=>0,'mailserver'=>0,'mailto'=>0,'maps'=>0,'market'=>0,'matrix'=>0,'message'=>0,'microsoft.windows.camera'=>0,'microsoft.windows.camera.multipicker'=>0,'microsoft.windows.camera.picker'=>0,'mid'=>0,'mms'=>0,'modem'=>0,'mongodb'=>0,'moz'=>0,'ms-access'=>0,'ms-browser-extension'=>0,'ms-calculator'=>0,'ms-drive-to'=>0,'ms-enrollment'=>0,'ms-excel'=>0,'ms-eyecontrolspeech'=>0,'ms-gamebarservices'=>0,'ms-gamingoverlay'=>0,'ms-getoffice'=>0,'ms-help'=>0,'ms-infopath'=>0,'ms-inputapp'=>0,'ms-lockscreencomponent-config'=>0,'ms-media-stream-id'=>0,'ms-meetnow'=>0,'ms-mixedrealitycapture'=>0,'ms-mobileplans'=>0,'ms-officeapp'=>0,'ms-people'=>0,'ms-project'=>0,'ms-powerpoint'=>0,'ms-publisher'=>0,'ms-restoretabcompanion'=>0,'ms-screenclip'=>0,'ms-screensketch'=>0,'ms-search'=>0,'ms-search-repair'=>0,'ms-secondary-screen-controller'=>0,'ms-secondary-screen-setup'=>0,'ms-settings'=>0,'ms-settings-airplanemode'=>0,'ms-settings-bluetooth'=>0,'ms-settings-camera'=>0,'ms-settings-cellular'=>0,'ms-settings-cloudstorage'=>0,'ms-settings-connectabledevices'=>0,'ms-settings-displays-topology'=>0,'ms-settings-emailandaccounts'=>0,'ms-settings-language'=>0,'ms-settings-location'=>0,'ms-settings-lock'=>0,'ms-settings-nfctransactions'=>0,'ms-settings-notifications'=>0,'ms-settings-power'=>0,'ms-settings-privacy'=>0,'ms-settings-proximity'=>0,'ms-settings-screenrotation'=>0,'ms-settings-wifi'=>0,'ms-settings-workplace'=>0,'ms-spd'=>0,'ms-sttoverlay'=>0,'ms-transit-to'=>0,'ms-useractivityset'=>0,'ms-virtualtouchpad'=>0,'ms-visio'=>0,'ms-walk-to'=>0,'ms-whiteboard'=>0,'ms-whiteboard-cmd'=>0,'ms-word'=>0,'msnim'=>0,'msrp'=>0,'msrps'=>0,'mss'=>0,'mt'=>0,'mtqp'=>0,'mumble'=>0,'mupdate'=>0,'mvn'=>0,'news'=>0,'nfs'=>0,'ni'=>0,'nih'=>0,'nntp'=>0,'notes'=>0,'num'=>0,'ocf'=>0,'oid'=>0,'onenote'=>0,'onenote-cmd'=>0,'opaquelocktoken'=>0,'openpgp4fpr'=>0,'otpauth'=>0,'pack'=>0,'palm'=>0,'paparazzi'=>0,'payment'=>0,'payto'=>0,'pkcs11'=>0,'platform'=>0,'pop'=>0,'pres'=>0,'prospero'=>0,'proxy'=>0,'pwid'=>0,'psyc'=>0,'pttp'=>0,'qb'=>0,'query'=>0,'quic-transport'=>0,'redis'=>0,'rediss'=>0,'reload'=>0,'res'=>0,'resource'=>0,'rmi'=>0,'rsync'=>0,'rtmfp'=>0,'rtmp'=>0,'rtsp'=>0,'rtsps'=>0,'rtspu'=>0,'sarif'=>0,'secondlife'=>0,'secret-token'=>0,'service'=>0,'session'=>0,'sftp'=>0,'sgn'=>0,'shc'=>0,'shttp (OBSOLETE)'=>0,'sieve'=>0,'simpleledger'=>0,'simplex'=>0,'sip'=>0,'sips'=>0,'skype'=>0,'smb'=>0,'smp'=>0,'sms'=>0,'smtp'=>0,'snews'=>0,'snmp'=>0,'soap.beep'=>0,'soap.beeps'=>0,'soldat'=>0,'spiffe'=>0,'spotify'=>0,'ssb'=>0,'ssh'=>0,'steam'=>0,'stun'=>0,'stuns'=>0,'submit'=>0,'svn'=>0,'swh'=>0,'swid'=>0,'swidpath'=>0,'tag'=>0,'teamspeak'=>0,'tel'=>0,'teliaeid'=>0,'telnet'=>0,'tftp'=>0,'things'=>0,'thismessage'=>0,'tip'=>0,'tn3270'=>0,'tool'=>0,'turn'=>0,'turns'=>0,'tv'=>0,'udp'=>0,'unreal'=>0,'urn'=>0,'ut2004'=>0,'uuid-in-package'=>0,'v-event'=>0,'vemmi'=>0,'ventrilo'=>0,'ves'=>0,'videotex'=>0,'vnc'=>0,'view-source'=>0,'vscode'=>0,'vscode-insiders'=>0,'vsls'=>0,'wais'=>0,'wcr'=>0,'webcal'=>0,'wifi'=>0,'wpid'=>0,'ws'=>0,'wss'=>0,'wtai'=>0,'wyciwyg'=>0,'xcon'=>0,'xcon-userid'=>0,'xfire'=>0,'xmlrpc.beep'=>0,'xmlrpc.beeps'=>0,'xmpp'=>0,'xri'=>0,'ymsgr'=>0,'z39.50'=>0,'z39.50r'=>0,'z39.50s'=>0,];
<?php return ['aaa'=>0,'aaas'=>0,'about'=>0,'acap'=>0,'acct'=>0,'acd'=>0,'acr'=>0,'adiumxtra'=>0,'adt'=>0,'afp'=>0,'afs'=>0,'aim'=>0,'amss'=>0,'android'=>0,'appdata'=>0,'apt'=>0,'ar'=>0,'ark'=>0,'attachment'=>0,'aw'=>0,'barion'=>0,'beshare'=>0,'bitcoin'=>0,'bitcoincash'=>0,'blob'=>0,'bolo'=>0,'browserext'=>0,'cabal'=>0,'calculator'=>0,'callto'=>0,'cap'=>0,'cast'=>0,'casts'=>0,'chrome'=>0,'chrome-extension'=>0,'cid'=>0,'coap'=>0,'coap+tcp'=>0,'coap+ws'=>0,'coaps'=>0,'coaps+tcp'=>0,'coaps+ws'=>0,'com-eventbrite-attendee'=>0,'content'=>0,'content-type'=>0,'crid'=>0,'cvs'=>0,'dab'=>0,'dat'=>0,'data'=>0,'dav'=>0,'diaspora'=>0,'dict'=>0,'did'=>0,'dis'=>0,'dlna-playcontainer'=>0,'dlna-playsingle'=>0,'dns'=>0,'dntp'=>0,'doi'=>0,'dpp'=>0,'drm'=>0,'drop'=>0,'dtmi'=>0,'dtn'=>0,'dvb'=>0,'dvx'=>0,'dweb'=>0,'ed2k'=>0,'elsi'=>0,'embedded'=>0,'ens'=>0,'ethereum'=>0,'example'=>0,'facetime'=>0,'fax'=>0,'feed'=>0,'feedready'=>0,'fido'=>0,'file'=>0,'filesystem'=>0,'finger'=>0,'first-run-pen-experience'=>0,'fish'=>0,'fm'=>0,'ftp'=>0,'fuchsia-pkg'=>0,'geo'=>0,'gg'=>0,'git'=>0,'gizmoproject'=>0,'go'=>0,'gopher'=>0,'graph'=>0,'gtalk'=>0,'h323'=>0,'ham'=>0,'hcap'=>0,'hcp'=>0,'http'=>0,'https'=>0,'hxxp'=>0,'hxxps'=>0,'hydrazone'=>0,'hyper'=>0,'iax'=>0,'icap'=>0,'icon'=>0,'im'=>0,'imap'=>0,'info'=>0,'iotdisco'=>0,'ipfs'=>0,'ipn'=>0,'ipns'=>0,'ipp'=>0,'ipps'=>0,'irc'=>0,'irc6'=>0,'ircs'=>0,'iris'=>0,'iris.beep'=>0,'iris.lwz'=>0,'iris.xpc'=>0,'iris.xpcs'=>0,'isostore'=>0,'itms'=>0,'jabber'=>0,'jar'=>0,'jms'=>0,'keyparc'=>0,'lastfm'=>0,'lbry'=>0,'ldap'=>0,'ldaps'=>0,'leaptofrogans'=>0,'lorawan'=>0,'lvlt'=>0,'magnet'=>0,'mailserver'=>0,'mailto'=>0,'maps'=>0,'market'=>0,'matrix'=>0,'message'=>0,'microsoft.windows.camera'=>0,'microsoft.windows.camera.multipicker'=>0,'microsoft.windows.camera.picker'=>0,'mid'=>0,'mms'=>0,'modem'=>0,'mongodb'=>0,'moz'=>0,'ms-access'=>0,'ms-browser-extension'=>0,'ms-calculator'=>0,'ms-drive-to'=>0,'ms-enrollment'=>0,'ms-excel'=>0,'ms-eyecontrolspeech'=>0,'ms-gamebarservices'=>0,'ms-gamingoverlay'=>0,'ms-getoffice'=>0,'ms-help'=>0,'ms-infopath'=>0,'ms-inputapp'=>0,'ms-lockscreencomponent-config'=>0,'ms-media-stream-id'=>0,'ms-meetnow'=>0,'ms-mixedrealitycapture'=>0,'ms-mobileplans'=>0,'ms-officeapp'=>0,'ms-people'=>0,'ms-project'=>0,'ms-powerpoint'=>0,'ms-publisher'=>0,'ms-restoretabcompanion'=>0,'ms-screenclip'=>0,'ms-screensketch'=>0,'ms-search'=>0,'ms-search-repair'=>0,'ms-secondary-screen-controller'=>0,'ms-secondary-screen-setup'=>0,'ms-settings'=>0,'ms-settings-airplanemode'=>0,'ms-settings-bluetooth'=>0,'ms-settings-camera'=>0,'ms-settings-cellular'=>0,'ms-settings-cloudstorage'=>0,'ms-settings-connectabledevices'=>0,'ms-settings-displays-topology'=>0,'ms-settings-emailandaccounts'=>0,'ms-settings-language'=>0,'ms-settings-location'=>0,'ms-settings-lock'=>0,'ms-settings-nfctransactions'=>0,'ms-settings-notifications'=>0,'ms-settings-power'=>0,'ms-settings-privacy'=>0,'ms-settings-proximity'=>0,'ms-settings-screenrotation'=>0,'ms-settings-wifi'=>0,'ms-settings-workplace'=>0,'ms-spd'=>0,'ms-stickers'=>0,'ms-sttoverlay'=>0,'ms-transit-to'=>0,'ms-useractivityset'=>0,'ms-virtualtouchpad'=>0,'ms-visio'=>0,'ms-walk-to'=>0,'ms-whiteboard'=>0,'ms-whiteboard-cmd'=>0,'ms-word'=>0,'msnim'=>0,'msrp'=>0,'msrps'=>0,'mss'=>0,'mt'=>0,'mtqp'=>0,'mumble'=>0,'mupdate'=>0,'mvn'=>0,'news'=>0,'nfs'=>0,'ni'=>0,'nih'=>0,'nntp'=>0,'notes'=>0,'num'=>0,'ocf'=>0,'oid'=>0,'onenote'=>0,'onenote-cmd'=>0,'opaquelocktoken'=>0,'openpgp4fpr'=>0,'otpauth'=>0,'pack'=>0,'palm'=>0,'paparazzi'=>0,'payment'=>0,'payto'=>0,'pkcs11'=>0,'platform'=>0,'pop'=>0,'pres'=>0,'prospero'=>0,'proxy'=>0,'pwid'=>0,'psyc'=>0,'pttp'=>0,'qb'=>0,'query'=>0,'quic-transport'=>0,'redis'=>0,'rediss'=>0,'reload'=>0,'res'=>0,'resource'=>0,'rmi'=>0,'rsync'=>0,'rtmfp'=>0,'rtmp'=>0,'rtsp'=>0,'rtsps'=>0,'rtspu'=>0,'sarif'=>0,'secondlife'=>0,'secret-token'=>0,'service'=>0,'session'=>0,'sftp'=>0,'sgn'=>0,'shc'=>0,'shttp (OBSOLETE)'=>0,'sieve'=>0,'simpleledger'=>0,'simplex'=>0,'sip'=>0,'sips'=>0,'skype'=>0,'smb'=>0,'smp'=>0,'sms'=>0,'smtp'=>0,'snews'=>0,'snmp'=>0,'soap.beep'=>0,'soap.beeps'=>0,'soldat'=>0,'spiffe'=>0,'spotify'=>0,'ssb'=>0,'ssh'=>0,'steam'=>0,'stun'=>0,'stuns'=>0,'submit'=>0,'svn'=>0,'swh'=>0,'swid'=>0,'swidpath'=>0,'tag'=>0,'teamspeak'=>0,'tel'=>0,'teliaeid'=>0,'telnet'=>0,'tftp'=>0,'things'=>0,'thismessage'=>0,'tip'=>0,'tn3270'=>0,'tool'=>0,'turn'=>0,'turns'=>0,'tv'=>0,'udp'=>0,'unreal'=>0,'urn'=>0,'ut2004'=>0,'uuid-in-package'=>0,'v-event'=>0,'vemmi'=>0,'ventrilo'=>0,'ves'=>0,'videotex'=>0,'vnc'=>0,'view-source'=>0,'vscode'=>0,'vscode-insiders'=>0,'vsls'=>0,'wais'=>0,'wcr'=>0,'webcal'=>0,'wifi'=>0,'wpid'=>0,'ws'=>0,'wss'=>0,'wtai'=>0,'wyciwyg'=>0,'xcon'=>0,'xcon-userid'=>0,'xfire'=>0,'xmlrpc.beep'=>0,'xmlrpc.beeps'=>0,'xmpp'=>0,'xri'=>0,'ymsgr'=>0,'z39.50'=>0,'z39.50r'=>0,'z39.50s'=>0,];
2 changes: 1 addition & 1 deletion data/suffixes.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Resolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function resolve(string $subject, Url $base): Url
return new Url($base->root() . $base->path() . $subject);
}

$subject = $this->resolveDots($subject, $base->path() ?? '');
$subject = $this->resolveDots($subject, $base->path() ?? '/');

if (substr($subject, 0, 2) === '//') {
return new Url($base->scheme() . ':' . $subject);
Expand Down
1 change: 1 addition & 0 deletions src/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public static function parse(string $url = ''): Url
*
* @param string $url
* @return Uri
* @throws InvalidUrlException
*/
public static function parsePsr7(string $url = ''): Uri
{
Expand Down
9 changes: 9 additions & 0 deletions tests/ResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ public function testResolveRelativeUrlAgainstBaseUrlWithEmptyPath(): void
$this->assertEquals('https://www.crwlr.software/privacy', $resolved->toString());
}

public function testResolveRelativePathWithoutLeadingSlashAgainstBaseUrlWithEmptyPath(): void
{
$resolver = new Resolver();
$this->assertEquals(
'https://www.otsch.codes/foo',
$resolver->resolve('foo', Url::parse('https://www.otsch.codes'))
);
}

/**
* When resolve() is called with an absolute url as subject, it should just return this absolute url.
*/
Expand Down

0 comments on commit ba7b44f

Please sign in to comment.