
Research
Security News
Malicious npm Packages Use Telegram to Exfiltrate BullX Credentials
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
replace-ext
Advanced tools
The replace-ext npm package is a utility for replacing the extension of a file path string. It is particularly useful in build processes and file manipulation tasks where you need to change file extensions programmatically.
Replace File Extension
This feature allows you to replace the extension of a given file path. In the code sample, the extension of 'file.txt' is changed to '.md', resulting in 'file.md'.
const replaceExt = require('replace-ext');
const filePath = 'example/file.txt';
const newFilePath = replaceExt(filePath, '.md');
console.log(newFilePath); // Outputs: 'example/file.md'
The 'path' module is a built-in Node.js module that provides utilities for working with file and directory paths. It includes the 'path.format' and 'path.parse' methods, which can be used to achieve similar functionality to replace-ext by manually changing the file extension.
The 'upath' package is a utility for working with file paths across different operating systems. It provides methods like 'upath.changeExt' which can be used to change the file extension, similar to replace-ext. However, upath offers additional cross-platform path handling features.
Replaces a file extension with another one.
var replaceExt = require('replace-ext');
var path = '/some/dir/file.js';
var newPath = replaceExt(path, '.coffee');
console.log(newPath); // /some/dir/file.coffee
replaceExt(path, extension)
Replaces the extension from path
with extension
and returns the updated path string.
Does not replace the extension if path
is not a string or is empty.
replace-ext
for enterpriseAvailable as part of the Tidelift Subscription.
The maintainers of replace-ext
and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.
MIT
FAQs
Replaces a file extension with another one.
The npm package replace-ext receives a total of 5,690,566 weekly downloads. As such, replace-ext popularity was classified as popular.
We found that replace-ext demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.
Security News
AI-generated slop reports are making bug bounty triage harder, wasting maintainer time, and straining trust in vulnerability disclosure programs.