> For the complete documentation index, see [llms.txt](https://appsecurity.gitbook.io/devops/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://appsecurity.gitbook.io/devops/ppc/ppc-langs/frontend/js-ts/javascript/cases/korrektno-normaliziruem-puti-v-js.md).

# Корректно нормализируем пути в JS

```javascript
import * as path from 'path';

const normalize = (rootPath, childPath) => {
   const normalizedPath = path.normalize(`${rootPath}/${childPath}`); 
   
   if (normalizedPath.startsWith(`${rootPath}/`)) {
      return normalizedPath;
   }

   return null;  
}
```
