Skip to content
This repository has been archived by the owner on Jul 10, 2022. It is now read-only.

Commit

Permalink
Path "" should be "/"
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikzogg committed Sep 7, 2021
1 parent f0340df commit f5d1a97
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ A simple PSR-7 http message implementation.
Through [NPM](https://www.npmjs.com) as [@chubbyjs/chubbyjs-http-message][1].

```sh
npm i @chubbyjs/chubbyjs-http-message@1.1.0
npm i @chubbyjs/chubbyjs-http-message@1.1.1
```

## Copyright
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@chubbyjs/chubbyjs-http-message",
"version": "1.1.0",
"version": "1.1.1",
"description": "A simple PSR-7 http message implementation.",
"keywords": [
"chubbyjs",
Expand Down
4 changes: 2 additions & 2 deletions src/Uri.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Uri implements UriInterface {
private userInfo: string = '';
private host: string = 'localhost';
private port: number | undefined = undefined;
private path: string = '';
private path: string = '/';
private query: string = '';
private fragment: string = '';

Expand All @@ -17,7 +17,7 @@ class Uri implements UriInterface {
.withUserInfo(url.username, url.password !== '' ? url.password : undefined)
.withHost(url.hostname)
.withPort(url.port ? parseInt(url.port) : undefined)
.withPath(url.pathname !== '/' ? url.pathname : '')
.withPath(url.pathname)
.withQuery(url.search ? url.search.substr(1) : '')
.withFragment(url.hash ? url.hash.substr(1) : '');
}
Expand Down
14 changes: 7 additions & 7 deletions tests/Uri.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import Uri from '../src/Uri';
describe('Uri', () => {
test('fromString', () => {
const uris = [
'https://example.com',
'https://user:password@example.com',
'https://user:password@example.com:8443',
'https://example.com/',
'https://user:password@example.com/',
'https://user:password@example.com:8443/',
'https://user:password@example.com:8443/path',
'https://user:password@example.com:8443/path?key=value',
'https://user:password@example.com:8443/path?key=value#title',
Expand Down Expand Up @@ -87,14 +87,14 @@ describe('Uri', () => {
test('get', () => {
const uri = new Uri();

expect(uri.getPath()).toBe('');
expect(uri.getPath()).toBe('/');
});

test('with', () => {
const uri = new Uri();

expect(uri.withPath('/')).not.toBe(uri);
expect(uri.withPath('/').getPath()).toBe('/');
expect(uri.withPath('/path')).not.toBe(uri);
expect(uri.withPath('/path').getPath()).toBe('/path');
});
});

Expand Down Expand Up @@ -148,7 +148,7 @@ describe('Uri', () => {

describe('toString', () => {
test('default', () => {
expect('' + new Uri()).toBe('http://localhost');
expect('' + new Uri()).toBe('http://localhost/');
});

test('overrides', () => {
Expand Down

0 comments on commit f5d1a97

Please sign in to comment.