Skip to content

Commit

Permalink
fix: normalize RSC URL path by absorbing leading/trailing slashes
Browse files Browse the repository at this point in the history
  • Loading branch information
AbanoubGhadban committed Jan 16, 2025
1 parent d72b824 commit 84b5cb5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion node_package/src/RSCClientRoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ const createFromFetch = async (fetchPromise: Promise<Response>) => {

const fetchRSC = ({ componentName, rscRenderingUrlPath }: RSCClientRootProps) => {
if (!renderCache[componentName]) {
renderCache[componentName] = createFromFetch(fetch(`${rscRenderingUrlPath}/${componentName}`)) as Promise<React.ReactNode>;
const strippedUrlPath = rscRenderingUrlPath.replace(/^\/|\/$/g, '');
renderCache[componentName] = createFromFetch(fetch(`/${strippedUrlPath}/${componentName}`)) as Promise<React.ReactNode>;
}
return renderCache[componentName];
}
Expand Down

0 comments on commit 84b5cb5

Please sign in to comment.