Socket
Socket
Sign inDemoInstall

gotiny

Package Overview
Dependencies
2
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.4.0 to 1.4.1

20

main/get.js

@@ -1,4 +0,4 @@

const axios = require("axios")
const axios = require('axios')
const get = async (code) => {
const get = async (code, opt = {}) => {
// If full link is provided, filter code out of it

@@ -11,12 +11,18 @@ const fullLinkRegex = /gotiny.cc\/(.{4,32})/

const requestURL = new URL('https://gotiny.cc/api/' + code)
// If extended option is present, add corresponding query params
if (opt.extended) {
requestURL.searchParams.set('format', 'json')
}
// Make request to API
try {
const res = await axios.get("https://gotiny.cc/api/" + code)
const res = await axios.get(requestURL.href)
return res.data
} catch (err) {
throw {
source: "sdk",
code: "not-found",
message: "GoTiny link not found",
source: 'sdk',
code: 'not-found',
message: 'GoTiny link not found',
}

@@ -23,0 +29,0 @@ }

{
"name": "gotiny",
"version": "1.4.0",
"version": "1.4.1",
"description": "SDK for GoTiny: A lightweight link shortener API",

@@ -13,2 +13,3 @@ "main": "index.js",

},
"keywords": ["url", "link", "shortener", "url shortener", "link shortener"],
"author": {

@@ -15,0 +16,0 @@ "name": "Rob van Bakel",

@@ -127,2 +127,4 @@ # GoTiny SDK

})
.then(res => console.log(res))
.catch(err => console.log(err))
```

@@ -132,3 +134,3 @@

To resolve a GoTiny link, pass the link as an argument in the `gotiny.get()` function
To resolve a GoTiny link, pass the link as an argument in the `gotiny.get()` function. The full link will return as plain text.

@@ -138,22 +140,15 @@ ```js

// Using Then
gotiny.get("https://gotiny.cc/y68hxc")
.then(res => console.log(res))
.then(res => console.log(res)) // https://amazon.com/very-long-url
.catch(err => console.log(err))
```
// Using Async/Await
Add an object with an `extended` key set to `true` as a second argument to return a more detailed object.
const resolveShortLink = async (input) => {
```js
const gotiny = require("gotiny")
try {
const res = await gotiny.get(input)
console.log(res)
} catch (err) {
console.log(err)
}
}
resolveShortLink("https://gotiny.cc/y68hxc")
gotiny.get("https://gotiny.cc/y68hxc" , { extended: true })
.then(res => console.log(res)) // { code: 'y68hxc', long: 'https://amazon.com/very-long-url' }
.catch(err => console.log(err))
```

@@ -160,0 +155,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc