Spaces:
Running
Running
ling-open-studio / node_modules /next /dist /client /components /router-reducer /set-cache-busting-search-param.js
| 'use client'; | |
| ; | |
| Object.defineProperty(exports, "__esModule", { | |
| value: true | |
| }); | |
| 0 && (module.exports = { | |
| setCacheBustingSearchParam: null, | |
| setCacheBustingSearchParamWithHash: null | |
| }); | |
| function _export(target, all) { | |
| for(var name in all)Object.defineProperty(target, name, { | |
| enumerable: true, | |
| get: all[name] | |
| }); | |
| } | |
| _export(exports, { | |
| setCacheBustingSearchParam: function() { | |
| return setCacheBustingSearchParam; | |
| }, | |
| setCacheBustingSearchParamWithHash: function() { | |
| return setCacheBustingSearchParamWithHash; | |
| } | |
| }); | |
| const _cachebustingsearchparam = require("../../../shared/lib/router/utils/cache-busting-search-param"); | |
| const _approuterheaders = require("../app-router-headers"); | |
| const setCacheBustingSearchParam = (url, headers)=>{ | |
| const uniqueCacheKey = (0, _cachebustingsearchparam.computeCacheBustingSearchParam)(headers[_approuterheaders.NEXT_ROUTER_PREFETCH_HEADER], headers[_approuterheaders.NEXT_ROUTER_SEGMENT_PREFETCH_HEADER], headers[_approuterheaders.NEXT_ROUTER_STATE_TREE_HEADER], headers[_approuterheaders.NEXT_URL]); | |
| setCacheBustingSearchParamWithHash(url, uniqueCacheKey); | |
| }; | |
| const setCacheBustingSearchParamWithHash = (url, hash)=>{ | |
| /** | |
| * Note that we intentionally do not use `url.searchParams.set` here: | |
| * | |
| * const url = new URL('https://example.com/search?q=custom%20spacing'); | |
| * url.searchParams.set('_rsc', 'abc123'); | |
| * console.log(url.toString()); // Outputs: https://example.com/search?q=custom+spacing&_rsc=abc123 | |
| * ^ <--- this is causing confusion | |
| * This is in fact intended based on https://url.spec.whatwg.org/#interface-urlsearchparams, but | |
| * we want to preserve the %20 as %20 if that's what the user passed in, hence the custom | |
| * logic below. | |
| */ const existingSearch = url.search; | |
| const rawQuery = existingSearch.startsWith('?') ? existingSearch.slice(1) : existingSearch; | |
| // Always remove any existing cache busting param and add a fresh one to ensure | |
| // we have the correct value based on current request headers | |
| const pairs = rawQuery.split('&').filter((pair)=>pair && !pair.startsWith(`${_approuterheaders.NEXT_RSC_UNION_QUERY}=`)); | |
| if (hash.length > 0) { | |
| pairs.push(`${_approuterheaders.NEXT_RSC_UNION_QUERY}=${hash}`); | |
| } else { | |
| pairs.push(`${_approuterheaders.NEXT_RSC_UNION_QUERY}`); | |
| } | |
| url.search = pairs.length ? `?${pairs.join('&')}` : ''; | |
| }; | |
| if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') { | |
| Object.defineProperty(exports.default, '__esModule', { value: true }); | |
| Object.assign(exports.default, exports); | |
| module.exports = exports.default; | |
| } | |
| //# sourceMappingURL=set-cache-busting-search-param.js.map |