Skip to content

Commit

Permalink
Leave pathname formatting up to the caller (vercel/turborepo#4776)
Browse files Browse the repository at this point in the history
### Description

Next.js code calling into `create_node_rendered_source` doesn't always
format the pathname with a leading `/`.

This PR removes all assumptions about the pathname from `turbopack-node`
and leaves the formatting up to the caller.

### Testing Instructions

N/A

Corresponding Next.js PR: #49085

link WEB-366
  • Loading branch information
alexkirsz authored May 3, 2023
1 parent 8981a07 commit c658062
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions crates/turbo-tasks-fs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,9 @@ impl FileSystemPath {
self.path.is_empty()
}

/// Returns the path of `inner` relative to `self`.
///
/// Note: this method always strips the leading `/` from the result.
pub fn get_path_to<'a>(&self, inner: &'a FileSystemPath) -> Option<&'a str> {
if self.fs != inner.fs {
return None;
Expand Down
4 changes: 2 additions & 2 deletions crates/turbopack-node/src/render/rendered_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,14 @@ impl GetContentSourceContent for NodeRenderGetContentResult {
url: url.clone(),
raw_query: raw_query.clone(),
raw_headers: raw_headers.clone(),
path: format!("/{}", source.pathname.await?),
path: source.pathname.await?.clone_value(),
data: Some(self.render_data.await?),
}
.cell(),
)
.issue_context(
entry.module.ident().path(),
format!("server-side rendering /{}", source.pathname.await?),
format!("server-side rendering {}", source.pathname.await?),
)
.await?;
Ok(match *result.await? {
Expand Down

0 comments on commit c658062

Please sign in to comment.