
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
next-url-parent
Advanced tools
A simple package to get the parent URL of the current URL in Next.js APP router.
Project starts on 30-03-2024
Get the parent URL of the current URL in Next.js APP router.
npm install next-url-parent
Visit the npm page.
package.json
Add the following code to package.json
:
"scripts": {
// other scripts ...
"mup@gen": "next-url-parent"
"mup@watch": "next-url-parent --watch"
},
Read 💻 CLI for more details.
[!NOTE]
You must run thenext-url-parent
command once to get the function and hook working.
import { getParentUrl } from "next-url-parent";
console.log(getParentUrl("https://example.com/parent/child"));
// -> "https://example.com/parent"
console.log(getParentUrl("https://example.com/parent/child?key1=value1&key2=value2", {
keepQueryString = true,
queryStringWhitelist = ["key1"],
}));
// -> "https://example.com/parent?key1=value1"
console.log(getParentUrl("https://example.com/parent/child?key1=value1&key2=value2", {
keepQueryString = true,
queryStringBlacklist = ["key1"],
}));
// -> "https://example.com/parent?key2=value2"
Option | Optional | Type | Default | Description |
---|---|---|---|---|
url | :x: | string | The child URL. | |
keepQueryString | ✅ | boolean | false | Keep the child URL query string. |
queryStringWhitelist | ✅ | string[] | [] | Whitelist of query string keys. |
queryStringBlacklist | ✅ | string[] | [] | Blacklist of query string keys. |
import { useUrlParent } from "next-url-parent";
const MyPage = () => {
const parentUrl = useUrlParent();
// Default Options
const parentUrl = useUrlParent(options: {
keepQueryString = false,
queryStringWhitelist = [],
queryStringBlacklist = [],
defaultParentUrl = "",
});
return (
<div>
<h1>Parent URL: {parentUrl}</h1>
</div>
);
};
Option | Optional | Type | Default | Description |
---|---|---|---|---|
keepQueryString | ✅ | boolean | false | Keep the child URL query string. |
queryStringWhitelist | ✅ | string[] | [] | Whitelist of query string keys. |
queryStringBlacklist | ✅ | string[] | [] | Blacklist of query string keys. |
defaultParentUrl | ✅ | string | "" | Default parent URL before the parent URL is resolved. |
next-url-parent --appDir=./src/app --watch
Generate a path map.
Option | Optional | Type | Default | Description |
---|---|---|---|---|
--appDir / -i | ✅ | string | ./src/app | The directory of the Next.js app. |
--watch / -w | ✅ | boolean | false | Watch the files and obfuscate on change. |
Contributions are welcome! If you find a bug or have a feature request, please open an issue.
This project is licensed under the MIT License - see the LICENSE file for details
Love it? Consider a donation to support my work.
FAQs
A simple package to get the parent URL of the current URL in Next.js APP router.
The npm package next-url-parent receives a total of 0 weekly downloads. As such, next-url-parent popularity was classified as not popular.
We found that next-url-parent demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.