18 lines
1.1 KiB
JavaScript
18 lines
1.1 KiB
JavaScript
import { revalidateTag } from "./revalidate-tag";
|
|
import { isDynamicRoute } from "../../../shared/lib/router/utils";
|
|
import { NEXT_CACHE_IMPLICIT_TAG_ID, NEXT_CACHE_SOFT_TAG_MAX_LENGTH } from "../../../lib/constants";
|
|
export function revalidatePath(originalPath, type) {
|
|
if (originalPath.length > NEXT_CACHE_SOFT_TAG_MAX_LENGTH) {
|
|
console.warn(`Warning: revalidatePath received "${originalPath}" which exceeded max length of ${NEXT_CACHE_SOFT_TAG_MAX_LENGTH}. See more info here https://nextjs.org/docs/app/api-reference/functions/revalidatePath`);
|
|
return;
|
|
}
|
|
let normalizedPath = `${NEXT_CACHE_IMPLICIT_TAG_ID}${originalPath}`;
|
|
if (type) {
|
|
normalizedPath += `${normalizedPath.endsWith("/") ? "" : "/"}${type}`;
|
|
} else if (isDynamicRoute(originalPath)) {
|
|
console.warn(`Warning: a dynamic page path "${originalPath}" was passed to "revalidatePath" without the "page" argument. This has no affect by default, see more info here https://nextjs.org/docs/app/api-reference/functions/revalidatePath`);
|
|
}
|
|
return revalidateTag(normalizedPath);
|
|
}
|
|
|
|
//# sourceMappingURL=revalidate-path.js.map
|