mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
refactor(core): Remove linting exceptions in nodes-base (no-changelog) (#4944)
This commit is contained in:
@@ -9,6 +9,36 @@ import {
|
||||
// Regular expressions used to extract binId from parameter value
|
||||
const BIN_ID_REGEX = /\b\d{13}-\d{13}\b/g;
|
||||
|
||||
/**
|
||||
* Extracts the PostBin Bin Id from the specified string.
|
||||
* This method should be able to extract bin Id from the
|
||||
* PostBin URL or from the string in the following format:
|
||||
* `Bin '<binId>'.`
|
||||
*
|
||||
*/
|
||||
function parseBinId(context: IExecuteSingleFunctions) {
|
||||
const binId = context.getNodeParameter('binId') as string;
|
||||
// Test if the Bin id is in the expected format
|
||||
BIN_ID_REGEX.lastIndex = 0;
|
||||
const idMatch = BIN_ID_REGEX.exec(binId);
|
||||
|
||||
// Return what is matched
|
||||
if (idMatch) {
|
||||
return idMatch[0];
|
||||
}
|
||||
|
||||
// If it's not recognized, error out
|
||||
throw new NodeApiError(
|
||||
context.getNode(),
|
||||
{},
|
||||
{
|
||||
message: 'Bin ID format is not valid',
|
||||
description: 'Please check the provided Bin ID and try again.',
|
||||
parseXml: false,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates correctly-formatted PostBin API URL based on the entered binId.
|
||||
* This function makes sure binId is in the expected format by parsing it
|
||||
@@ -60,36 +90,6 @@ export async function buildRequestURL(
|
||||
return requestOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the PostBin Bin Id from the specified string.
|
||||
* This method should be able to extract bin Id from the
|
||||
* PostBin URL or from the string in the following format:
|
||||
* `Bin '<binId>'.`
|
||||
*
|
||||
*/
|
||||
function parseBinId(context: IExecuteSingleFunctions) {
|
||||
const binId = context.getNodeParameter('binId') as string;
|
||||
// Test if the Bin id is in the expected format
|
||||
BIN_ID_REGEX.lastIndex = 0;
|
||||
const idMatch = BIN_ID_REGEX.exec(binId);
|
||||
|
||||
// Return what is matched
|
||||
if (idMatch) {
|
||||
return idMatch[0];
|
||||
}
|
||||
|
||||
// If it's not recognized, error out
|
||||
throw new NodeApiError(
|
||||
context.getNode(),
|
||||
{},
|
||||
{
|
||||
message: 'Bin ID format is not valid',
|
||||
description: 'Please check the provided Bin ID and try again.',
|
||||
parseXml: false,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the bin response data and adds additional properties
|
||||
*
|
||||
@@ -107,8 +107,8 @@ export async function transformBinReponse(
|
||||
nowIso: new Date(item.json.now as string).toISOString(),
|
||||
expiresTimestamp: item.json.expires,
|
||||
expiresIso: new Date(item.json.expires as string).toISOString(),
|
||||
requestUrl: 'https://www.toptal.com/developers/postbin/' + item.json.binId,
|
||||
viewUrl: 'https://www.toptal.com/developers/postbin/b/' + item.json.binId,
|
||||
requestUrl: 'https://www.toptal.com/developers/postbin/' + (item.json.binId as string),
|
||||
viewUrl: 'https://www.toptal.com/developers/postbin/b/' + (item.json.binId as string),
|
||||
}),
|
||||
);
|
||||
return items;
|
||||
|
||||
Reference in New Issue
Block a user