Skip to content

Commit

Permalink
Merge pull request #8 from polarityio/develop
Browse files Browse the repository at this point in the history
Add support for URLs without a leading scheme
  • Loading branch information
sarus committed Aug 16, 2023
2 parents 12eb2b0 + ab14a1c commit ed027ae
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 80 deletions.
11 changes: 8 additions & 3 deletions config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@ module.exports = {
* @type String
* @optional
*/
description: 'Unshorten.me is a free service to Un-Shorten the URLs created by URL shortening services.',
entityTypes: ['url'],
description: 'Un-Shorten URLs created by URL shortening services using the unshorten.me API.',
customTypes: [
{
key: 'domain-url',
regex: /((https|http)?:\/\/)?([a-zA-Z0-9-]{1,256})\.([a-z]{2,10})\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/
}
],
defaultColor: 'light-gray',
/**
* Provide custom component logic and template for rendering the integration details block. If you do not
Expand Down Expand Up @@ -58,7 +63,7 @@ module.exports = {
ca: '',
// An HTTP proxy to be used. Supports proxy Auth with Basic Auth, identical to support for
// the url parameter (by embedding the auth info in the uri)
proxy: ""
proxy: ''
},
logging: {
level: 'info' //trace, debug, info, warn, error, fatal
Expand Down
11 changes: 8 additions & 3 deletions config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
"name": "Unshorten.me",
"acronym": "UME",
"onDemandOnly": true,
"description": "Unshorten.me is a free service to Un-Shorten the URLs created by URL shortening services.",
"entityTypes": ["url"],
"description": "Un-Shorten URLs created by URL shortening services using the unshorten.me API.",
"customTypes": [
{
"key": "domain-url",
"regex": "((https|http)?:\\\\/\\\\/)?([a-zA-Z0-9-]{1,256})\\\\.([a-z]{2,10})\\\\b([-a-zA-Z0-9@:%_\\\\+.~#?&//=]*)"
}
],
"defaultColor": "light-gray",
"block": {
"component": {
Expand Down Expand Up @@ -36,4 +41,4 @@
"adminOnly": true
}
]
}
}
13 changes: 3 additions & 10 deletions integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,7 @@ function _getUrlShortener(url) {
let tokens = urlWithoutSchema.split('/');

// If something goes wrong so just return an empty string
return tokens.length > 0 ?
tokens[0]
.trim()
.toLowerCase()
.split('.')
.slice(-2)
.join('.') :
'';
return tokens.length > 0 ? tokens[0].trim().toLowerCase().split('.').slice(-2).join('.') : '';
}

function doLookup(entities, options, cb) {
Expand Down Expand Up @@ -128,8 +121,8 @@ function doLookup(entities, options, cb) {

Logger.trace({ uri: requestOptions }, 'Request URI');

tasks.push(function(done) {
requestWithDefaults(requestOptions, function(error, res, body) {
tasks.push(function (done) {
requestWithDefaults(requestOptions, function (error, res, body) {
if (error) {
return done({
detail: 'HTTP Request Error',
Expand Down
144 changes: 84 additions & 60 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "Unshorten.me",
"version": "3.0.5",
"version": "3.1.0",
"main": "./integration.js",
"private": true,
"scripts": {
"update:urls": "node -e \"require('./lib/update-lists').run()\""
},
"dependencies": {
"async": "^2.6",
"async": "^3.2.4",
"node-schedule": "^1.3.2",
"postman-request": "^2.88.1-postman.31"
"postman-request": "^2.88.1-postman.33"
}
}
}

0 comments on commit ed027ae

Please sign in to comment.