Repository: remix-run/react-router
File: packages/react-router/lib/server-runtime/server.ts (TypeScript)

Code before:
      normalizedPath = normalizedPath.replace(/\.data$/, "");
    }

    if (
      stripBasename(normalizedPath, normalizedBasename) !== "/" &&
      normalizedPath.endsWith("/")
    ) {
      normalizedPath = normalizedPath.slice(0, -1);
    }

    let isSpaMode =
      getBuildTimeHeader(request, "X-React-Router-SPA-Mode") === "yes";

    // When runtime SSR is disabled, make our dev server behave like the deployed
    // pre-rendered site would
    if (!_build.ssr) {
      // Decode the URL path before checking against the prerender config
      let decodedPath = decodeURI(normalizedPath);

      if (normalizedBasename !== "/") {
        let strippedPath = stripBasename(decodedPath, normalizedBasename);
        if (strippedPath == null) {
          // 404 on non-pre-rendered `.data` requests
          errorHandler(
            new ErrorResponseImpl(
              404,
              "Not Found",
              `Refusing to prerender the \`${decodedPath}\` path because it does ` +
                `not start with the basename \`${normalizedBasename}\``,
            ),
            {
              context: loadContext,
              params,
              request,
            },
          );
          return new Response("Not Found", {
            status: 404,
            statusText: "Not Found",
          });
        }
        decodedPath = strippedPath;
      }

      // When SSR is disabled this, file can only ever run during dev because we
      // delete the server build at the end of the build
      if (_build.prerender.length === 0) {
        // ssr:false and no prerender config indicates "SPA Mode"
        isSpaMode = true;
      } else if (
        !_build.prerender.includes(decodedPath) &&

Review comment (suggestion):
I don't think we needed this check because we just add the trailing slash back on below in `!_build.prerender.includes(decodedPath + "/")`

Code after:
      normalizedPath = normalizedPath.replace(/\.data$/, "");
    }

    if (
      stripBasename(normalizedPath, normalizedBasename) !== "/" &&
      normalizedPath.endsWith("/")
    ) {
      normalizedPath = normalizedPath.slice(0, -1);
    }

    let isSpaMode =
      getBuildTimeHeader(request, "X-React-Router-SPA-Mode") === "yes";

    // When runtime SSR is disabled, make our dev server behave like the deployed
    // pre-rendered site would
    if (!_build.ssr) {
      // Decode the URL path before checking against the prerender config
      let decodedPath = decodeURI(normalizedPath);

      if (normalizedBasename !== "/") {
        let strippedPath = stripBasename(decodedPath, normalizedBasename);
        if (strippedPath == null) {
          errorHandler(
            new ErrorResponseImpl(
              404,
              "Not Found",
              `Refusing to prerender the \`${decodedPath}\` path because it does ` +
                `not start with the basename \`${normalizedBasename}\``,
            ),
            {
              context: loadContext,
              params,
              request,
            },
          );
          return new Response("Not Found", {
            status: 404,
            statusText: "Not Found",
          });
        }
        decodedPath = strippedPath;
      }

      // When SSR is disabled this, file can only ever run during dev because we
      // delete the server build at the end of the build
      if (_build.prerender.length === 0) {
        // ssr:false and no prerender config indicates "SPA Mode"
        isSpaMode = true;
      } else if (
        !_build.prerender.includes(decodedPath) &&
        !_build.prerender.includes(decodedPath + "/")