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.3.1 to 1.4.0

17

main/set.js
const axios = require("axios")
const set = async (input, opt) => {
if (input?.replace(/\s/g, "") === "") {
const set = async (payload) => {
// Throw error if no input is provided
if (!payload) {
throw {
source: "sdk",
code: "missing-argument",
message: "Empty string provided",
message: "No input provided",
}
}
if (!input) {
throw {
source: "sdk",
code: "missing-argument",
message: "No string provided",
}
if (typeof payload === "string") {
payload = { input: payload }
}
// Make request to API
const res = await axios.post("https://gotiny.cc/api", { input, ...opt })
const res = await axios.post("https://gotiny.cc/api", payload)
const data = res.data

@@ -23,0 +20,0 @@

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

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -10,5 +10,5 @@ # GoTiny SDK

- [Create GoTiny link](#create-gotiny-link)
- [Options](#options)
- [Automatic URL Parsing](#automatic-url-parsing)
- [Options](#options)
- [Resolve GoTiny link](#resolve-gotiny-link)
- [Automatic URL Parsing](#automatic-url-parsing)
- [About GoTiny Links](#about-gotiny-links)

@@ -68,3 +68,3 @@ - [Privacy](#privacy)

;[
[
{

@@ -79,15 +79,49 @@ long: "https://amazon.com/very-long-url",

#### Automatic URL Parsing
GoTiny automatically filters URLs from the user input. This way, you as a developer won't have to provide a clean link, but can just feed an entire paragraph into GoTiny. It will create a short url from every url that it finds and include it in the response array.
Example response:
```js
// gotiny.set("The top 3 most popular websites are youtube.com, www.google.com and apple.com.")
[
{
long: "youtube.com",
code: "86df6c",
tiny: "gotiny.cc/86df6c",
link: "https://gotiny.cc/86df6c",
},
{
long: "www.google.com",
code: "6wrsnf",
tiny: "gotiny.cc/6wrsnf",
link: "https://gotiny.cc/6wrsnf",
},
{
long: "apple.com",
code: "c56ned",
tiny: "gotiny.cc/c56ned",
link: "https://gotiny.cc/c56ned",
},
];
```
Note that you’re not required to use the `long` attribute in your code. GoTiny will automatically resolve the short link in the users web browser to point to the original url.
### Options
#### Options
Options are provided by passing an object as a second argument to the `gotiny.set()` function. Options currently supported are:
Options are provided by passing an object to the `gotiny.set()` function. The object should have a `long` key with the long link as a value, as wel as any of the supported options. Options currently supported are:
| Key | Type | Description |
| :------------ | :------ | :------------------------------------------------------------------------------------------ |
| `custom` | string | Should consist of 4-32 lowercase letters, numbers, hyphen and/or underscore symbols |
| `useFallback` | boolean | Set to `false` if you don't want to generate a random code when a custom code can't be used |
| `custom` | string | Generates a custom link (e.g. `gotiny.cc/custom-link`). Custom codes should consist of 4-32 lowercase letters, numbers, `-` and/or `_` symbols. |
| `useFallback` | boolean | Set to `false` if you don't want to use a randomly generated 6-character fallback code and throw an error instead when a custom code can't be used. |
To generate multiple links at once, you can pass an array of objects in to the `gotiny.set()` function.
```js
gotiny.set("https://amazon.com/very-long-url", {
gotiny.set({
long: "https://amazon.com/very-long-url",
custom: "amazon", // generate gotiny.cc/amazon

@@ -129,33 +163,2 @@ useFallback: false // don't use randomly generated code when "amazon" can't be used

## Automatic URL Parsing
GoTiny automatically filters URLs from the user input. This way, you as a developer won't have to provide a clean link, but can just feed an entire paragraph into GoTiny. It will create a short url from every url that it finds and include it in the response array.
Example response:
```js
// gotiny.set("The top 3 most popular websites are youtube.com, www.google.com and apple.com.")
[
{
long: "youtube.com",
code: "86df6c",
tiny: "gotiny.cc/86df6c",
link: "https://gotiny.cc/86df6c",
},
{
long: "www.google.com",
code: "6wrsnf",
tiny: "gotiny.cc/6wrsnf",
link: "https://gotiny.cc/6wrsnf",
},
{
long: "apple.com",
code: "c56ned",
tiny: "gotiny.cc/c56ned",
link: "https://gotiny.cc/c56ned",
},
];
```
## About GoTiny Links

@@ -162,0 +165,0 @@ The unique links that GoTiny generates are always 16 characters long, including the domain name. GoTiny links are all lowercase and don't include characters that could be confused with each other (e.g. o/0 or 1/i/l).

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