fix(Google Drive Node): Fix regex in file RLC (#6607)

This commit is contained in:
Michael Kret 2023-07-05 23:15:13 +03:00 committed by GitHub
parent 8abb03d7cf
commit 56721468df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 37 additions and 52 deletions

View file

@ -13,6 +13,7 @@ import { extractId, googleApiRequest, googleApiRequestAllItems } from './v1/Gene
import moment from 'moment';
import { fileSearch, folderSearch } from './v1/SearchFunctions';
import { GOOGLE_DRIVE_FILE_URL_REGEX, GOOGLE_DRIVE_FOLDER_URL_REGEX } from '../constants';
export class GoogleDriveTrigger implements INodeType {
description: INodeTypeDescription = {
@ -112,15 +113,13 @@ export class GoogleDriveTrigger implements INodeType {
placeholder: 'https://drive.google.com/file/d/1wroCSfK-hupQIYf_xzeoUEzOhvfTFH2P/edit',
extractValue: {
type: 'regex',
regex:
'https:\\/\\/(?:drive|docs)\\.google\\.com(?:\\/.*|)\\/d\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FILE_URL_REGEX,
},
validation: [
{
type: 'regex',
properties: {
regex:
'https:\\/\\/(?:drive|docs)\\.google.com(?:\\/.*|)\\/d\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FILE_URL_REGEX,
errorMessage: 'Not a valid Google Drive File URL',
},
},
@ -192,15 +191,13 @@ export class GoogleDriveTrigger implements INodeType {
placeholder: 'https://drive.google.com/drive/folders/1Tx9WHbA3wBpPB4C_HcoZDH9WZFWYxAMU',
extractValue: {
type: 'regex',
regex:
'https:\\/\\/drive\\.google\\.com(?:\\/.*|)\\/folders\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FOLDER_URL_REGEX,
},
validation: [
{
type: 'regex',
properties: {
regex:
'https:\\/\\/drive\\.google\\.com(?:\\/.*|)\\/folders\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FOLDER_URL_REGEX,
errorMessage: 'Not a valid Google Drive Folder URL',
},
},

View file

@ -17,6 +17,7 @@ import type { Readable } from 'stream';
import { driveSearch, fileSearch, folderSearch } from './SearchFunctions';
import { oldVersionNotice } from '@utils/descriptions';
import { GOOGLE_DRIVE_FILE_URL_REGEX, GOOGLE_DRIVE_FOLDER_URL_REGEX } from '../../constants';
const UPLOAD_CHUNK_SIZE = 256 * 1024;
@ -242,15 +243,13 @@ const versionDescription: INodeTypeDescription = {
'https://drive.google.com/file/d/1anGBg0b5re2VtF2bKu201_a-Vnz5BHq9Y4r-yBDAj5A/edit',
extractValue: {
type: 'regex',
regex:
'https:\\/\\/(?:drive|docs)\\.google\\.com\\/\\w+\\/d\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FILE_URL_REGEX,
},
validation: [
{
type: 'regex',
properties: {
regex:
'https:\\/\\/(?:drive|docs)\\.google.com\\/\\w+\\/d\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FILE_URL_REGEX,
errorMessage: 'Not a valid Google Drive File URL',
},
},
@ -306,15 +305,13 @@ const versionDescription: INodeTypeDescription = {
placeholder: 'https://drive.google.com/drive/folders/1Tx9WHbA3wBpPB4C_HcoZDH9WZFWYxAMU',
extractValue: {
type: 'regex',
regex:
'https:\\/\\/drive\\.google\\.com\\/\\w+\\/folders\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FOLDER_URL_REGEX,
},
validation: [
{
type: 'regex',
properties: {
regex:
'https:\\/\\/drive\\.google\\.com\\/\\w+\\/folders\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FOLDER_URL_REGEX,
errorMessage: 'Not a valid Google Drive Folder URL',
},
},
@ -1489,15 +1486,13 @@ const versionDescription: INodeTypeDescription = {
placeholder: 'https://drive.google.com/drive/folders/0AaaaaAAAAAAAaa',
extractValue: {
type: 'regex',
regex:
'https:\\/\\/drive\\.google\\.com\\/\\w+\\/folders\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FOLDER_URL_REGEX,
},
validation: [
{
type: 'regex',
properties: {
regex:
'https:\\/\\/drive\\.google\\.com\\/\\w+\\/folders\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FOLDER_URL_REGEX,
errorMessage: 'Not a valid Google Drive Drive URL',
},
},

View file

@ -1,5 +1,6 @@
import type { INodeProperties } from 'n8n-workflow';
import { DRIVE, RLC_DRIVE_DEFAULT } from '../helpers/interfaces';
import { GOOGLE_DRIVE_FILE_URL_REGEX, GOOGLE_DRIVE_FOLDER_URL_REGEX } from '../../../constants';
export const fileRLC: INodeProperties = {
displayName: 'File',
@ -26,15 +27,13 @@ export const fileRLC: INodeProperties = {
'e.g. https://drive.google.com/file/d/1anGBg0b5re2VtF2bKu201_a-Vnz5BHq9Y4r-yBDAj5A/edit',
extractValue: {
type: 'regex',
regex:
'https:\\/\\/(?:drive|docs)\\.google\\.com\\/\\w+\\/d\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FILE_URL_REGEX,
},
validation: [
{
type: 'regex',
properties: {
regex:
'https:\\/\\/(?:drive|docs)\\.google.com\\/\\w+\\/d\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FILE_URL_REGEX,
errorMessage: 'Not a valid Google Drive File URL',
},
},
@ -84,15 +83,13 @@ export const folderNoRootRLC: INodeProperties = {
placeholder: 'e.g. https://drive.google.com/drive/folders/1Tx9WHbA3wBpPB4C_HcoZDH9WZFWYxAMU',
extractValue: {
type: 'regex',
regex:
'https:\\/\\/drive\\.google\\.com(?:\\/.*|)\\/folders\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FOLDER_URL_REGEX,
},
validation: [
{
type: 'regex',
properties: {
regex:
'https:\\/\\/drive\\.google\\.com(?:\\/.*|)\\/folders\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FOLDER_URL_REGEX,
errorMessage: 'Not a valid Google Drive Folder URL',
},
},
@ -142,15 +139,13 @@ export const folderRLC: INodeProperties = {
placeholder: 'e.g. https://drive.google.com/drive/folders/1Tx9WHbA3wBpPB4C_HcoZDH9WZFWYxAMU',
extractValue: {
type: 'regex',
regex:
'https:\\/\\/drive\\.google\\.com(?:\\/.*|)\\/folders\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FOLDER_URL_REGEX,
},
validation: [
{
type: 'regex',
properties: {
regex:
'https:\\/\\/drive\\.google\\.com(?:\\/.*|)\\/folders\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FOLDER_URL_REGEX,
errorMessage: 'Not a valid Google Drive Folder URL',
},
},
@ -200,15 +195,13 @@ export const driveRLC: INodeProperties = {
placeholder: 'https://drive.google.com/drive/folders/0AaaaaAAAAAAAaa',
extractValue: {
type: 'regex',
regex:
'https:\\/\\/drive\\.google\\.com(?:\\/.*|)\\/folders\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FOLDER_URL_REGEX,
},
validation: [
{
type: 'regex',
properties: {
regex:
'https:\\/\\/drive\\.google\\.com(?:\\/.*|)\\/folders\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FOLDER_URL_REGEX,
errorMessage: 'Not a valid Google Drive Drive URL',
},
},
@ -258,15 +251,13 @@ export const sharedDriveRLC: INodeProperties = {
placeholder: 'e.g. https://drive.google.com/drive/u/1/folders/0AIjtcbwnjtcbwn9PVA',
extractValue: {
type: 'regex',
regex:
'https:\\/\\/drive\\.google\\.com(?:\\/.*|)\\/folders\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FOLDER_URL_REGEX,
},
validation: [
{
type: 'regex',
properties: {
regex:
'https:\\/\\/drive\\.google\\.com(?:\\/.*|)\\/folders\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FOLDER_URL_REGEX,
errorMessage: 'Not a valid Google Drive Drive URL',
},
},

View file

@ -20,6 +20,7 @@ import {
getRevisionFile,
sheetBinaryToArrayOfArrays,
} from './GoogleSheetsTrigger.utils';
import { GOOGLE_DRIVE_FILE_URL_REGEX } from '../constants';
export class GoogleSheetsTrigger implements INodeType {
description: INodeTypeDescription = {
@ -84,15 +85,13 @@ export class GoogleSheetsTrigger implements INodeType {
type: 'string',
extractValue: {
type: 'regex',
regex:
'https:\\/\\/(?:drive|docs)\\.google\\.com(?:\\/.*|)\\/d\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FILE_URL_REGEX,
},
validation: [
{
type: 'regex',
properties: {
regex:
'https:\\/\\/(?:drive|docs)\\.google.com(?:\\/.*|)\\/d\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FILE_URL_REGEX,
errorMessage: 'Not a valid Google Drive File URL',
},
},

View file

@ -7,6 +7,7 @@ import * as del from './delete.operation';
import * as read from './read.operation';
import * as remove from './remove.operation';
import * as update from './update.operation';
import { GOOGLE_DRIVE_FILE_URL_REGEX } from '../../../../constants';
export { append, appendOrUpdate, clear, create, del as delete, read, remove, update };
@ -96,15 +97,13 @@ export const descriptions: INodeProperties[] = [
type: 'string',
extractValue: {
type: 'regex',
regex:
'https:\\/\\/(?:drive|docs)\\.google\\.com(?:\\/.*|)\\/d\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FILE_URL_REGEX,
},
validation: [
{
type: 'regex',
properties: {
regex:
'https:\\/\\/(?:drive|docs)\\.google.com(?:\\/.*|)\\/d\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FILE_URL_REGEX,
errorMessage: 'Not a valid Google Drive File URL',
},
},

View file

@ -1,6 +1,7 @@
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
import type { SpreadSheetProperties } from '../../helpers/GoogleSheets.types';
import { apiRequest } from '../../transport';
import { GOOGLE_DRIVE_FILE_URL_REGEX } from '../../../../constants';
export const description: SpreadSheetProperties = [
// {
@ -37,15 +38,13 @@ export const description: SpreadSheetProperties = [
type: 'string',
extractValue: {
type: 'regex',
regex:
'https:\\/\\/(?:drive|docs)\\.google\\.com(?:\\/.*|)\\/d\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FILE_URL_REGEX,
},
validation: [
{
type: 'regex',
properties: {
regex:
'https:\\/\\/(?:drive|docs)\\.google.com(?:\\/.*|)\\/d\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FILE_URL_REGEX,
errorMessage: 'Not a valid Google Drive File URL',
},
},

View file

@ -0,0 +1,5 @@
export const GOOGLE_DRIVE_FILE_URL_REGEX =
'https:\\/\\/(?:drive|docs)\\.google\\.com(?:\\/.*|)\\/d\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)';
export const GOOGLE_DRIVE_FOLDER_URL_REGEX =
'https:\\/\\/drive\\.google\\.com(?:\\/.*|)\\/folders\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)';