Skip to content

Commit

Permalink
feat: add hideuri
Browse files Browse the repository at this point in the history
  • Loading branch information
mohantakeo committed Aug 26, 2022
1 parent 795ea82 commit d379238
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Type: `object`
Type: `string`

Service to use for shortening links. Defaults to `isgd`
Available providers: `''isgd' | 'cdpt' | 'vgd' | '4hnet' | 'tinube' | 'rbgy' | 'vurl' | 'haha' | 'pwm' | 'cya'`
Available providers: `''isgd' | 'cdpt' | 'vgd' | '4hnet' | 'tinube' | 'rbgy' | 'vurl' | 'haha' | 'pwm' | 'cya' | 'hideuri`

##### timeout

Expand All @@ -71,6 +71,7 @@ Url shortner supports the following providers.
| pwn.se | ✔️ |
| haha.se | ✔️ |
| cya.se | ✔️ |
| hideuri.com | ✔️ |

## Contributing

Expand Down
12 changes: 11 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import axios from 'axios';



type providers = 'isgd' | 'cdpt' | 'vgd' | '4hnet' | 'tinube' | 'rbgy' | 'vurl' | 'haha' | 'pwm' | 'cya';
type providers = 'isgd' | 'cdpt' | 'vgd' | '4hnet' | 'tinube' | 'rbgy' | 'vurl' | 'haha' | 'pwm' | 'cya' | 'hideuri';

/**
*
Expand Down Expand Up @@ -59,6 +59,8 @@ function responseMap(response: Record<any, any>, longUrl: string,provider: provi
return { longUrl, shortUrl: response.data.short };
} else if (response.data?.short_url) {
return { longUrl, shortUrl: response.data.short_url };
} else if (response.data?.result_url) {
return { longUrl, shortUrl: response.data.result_url };
}
}

Expand Down Expand Up @@ -143,6 +145,14 @@ const ValidProviders: Record<string, IProviders> = {
},
},

hideuri: {
url: 'https://hideuri.com/api/v1/shorten',
method: 'post',
body: (val: string) => {
return { url: val };
},
},

rbgy: {
url: 'https://free-url-shortener.rb.gy/shorten',
method: 'post',
Expand Down
5 changes: 5 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ describe('should get a shortened url', () => {
expect(response.shortUrl).toMatch(/^https:\/\/4h.net\//);
});

it('should get shortened url with hideuri.com', async () => {
const response = await minify(url, { provider: 'hideuri' });
expect(response.shortUrl).toMatch(/^https:\/\/hideuri.com\//);
});

it('should get shortened url with tinu.be', async () => {
const response = await minify(url, { provider: 'tinube' });
expect(response.shortUrl).toMatch(/^https:\/\/tinu.be\//);
Expand Down

0 comments on commit d379238

Please sign in to comment.