From d379238c837ef558661f908f759a0245aa8762cd Mon Sep 17 00:00:00 2001 From: Rubin Bhandari Date: Fri, 26 Aug 2022 23:13:34 +0545 Subject: [PATCH] feat: add hideuri --- README.md | 3 ++- src/index.ts | 12 +++++++++++- test/index.test.ts | 5 +++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index af41e1d..cd8d7d9 100644 --- a/README.md +++ b/README.md @@ -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 @@ -71,6 +71,7 @@ Url shortner supports the following providers. | pwn.se | ✔️ | | haha.se | ✔️ | | cya.se | ✔️ | +| hideuri.com | ✔️ | ## Contributing diff --git a/src/index.ts b/src/index.ts index 651f051..d785a6b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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'; /** * @@ -59,6 +59,8 @@ function responseMap(response: Record, 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 }; } } @@ -143,6 +145,14 @@ const ValidProviders: Record = { }, }, + 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', diff --git a/test/index.test.ts b/test/index.test.ts index 0ee2282..fa8f060 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -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\//);