1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-11 14:20:05 +00:00

refactor: added isUri utility

This commit is contained in:
Yury Shkoda
2020-09-08 17:24:49 +03:00
parent 0a77ebf5c5
commit e056ca21fe
28 changed files with 3122 additions and 24 deletions

View File

@@ -2,7 +2,8 @@ import {
isAuthorizeFormRequired,
parseAndSubmitAuthorizeForm,
convertToCSV,
makeRequest
makeRequest,
isUri
} from './utils'
import * as NodeFormData from 'form-data'
import * as path from 'path'
@@ -1154,14 +1155,12 @@ export class SASViyaApiClient {
accessToken: string
) {
// checks if 'sourceFolder' is already a URI
const sourceFolderUri = /^\/folders\/folders\//.test(sourceFolder)
const sourceFolderUri = isUri(sourceFolder)
? sourceFolder
: await this.getFolderUri(sourceFolder, accessToken)
// checks if 'targetParentFolder' is already a URI
const targetParentFolderUri = /^\/folders\/folders\//.test(
targetParentFolder
)
const targetParentFolderUri = isUri(targetParentFolder)
? targetParentFolder
: await this.getFolderUri(targetParentFolder, accessToken)

View File

@@ -13,3 +13,4 @@ export * from './parseSasViyaLog'
export * from './serialize'
export * from './splitChunks'
export * from './parseWeboutResponse'
export * from './isUri'

5
src/utils/isUri.ts Normal file
View File

@@ -0,0 +1,5 @@
/**
* Checks if string is in URI format
* @param str string to check
*/
export const isUri = (str: string): boolean => /^\/folders\/folders\//.test(str)