diff --git a/src/services/includers/batteries/unarchive.ts b/src/services/includers/batteries/unarchive.ts index d04ae90d..a743da0a 100644 --- a/src/services/includers/batteries/unarchive.ts +++ b/src/services/includers/batteries/unarchive.ts @@ -4,6 +4,8 @@ import {Headers, extract} from 'tar-stream'; import type {PassThrough} from 'stream'; +import {getRealPath} from '@diplodoc/transform/lib/utilsFS'; + import {IncluderFunctionParams} from '../../../models'; const name = 'unarchive'; @@ -87,10 +89,13 @@ async function includerFunction(params: IncluderFunctionParams) { const contentPath = index === 0 ? join(writeBasePath, input) : join(readBasePath, input); - const writePath = join(writeBasePath, output); + const writePath = getRealPath(join(writeBasePath, output)); - if(!writePath.startsWith(writeBasePath)){ - throw new UnarchiveIncluderError(`Invalid output parameter: ${output}. Provide includer with output parameter, which is located inside the documentation`, output); + if (!writePath.startsWith(writeBasePath)) { + throw new UnarchiveIncluderError( + `Expected the output parameter to be located inside project root, got: ${output}`, + output, + ); } try {