vike 0.4.180-commit-648cd01 → 0.4.181-commit-ee50efa
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/node/plugin/plugins/envVars.js +7 -12
- package/dist/cjs/node/runtime/renderPage/createHttpResponseObject/assertNoInfiniteHttpRedirect.js +1 -2
- package/dist/cjs/{shared/route → node/runtime/renderPage}/resolveRedirects.js +9 -11
- package/dist/cjs/node/runtime/renderPage.js +6 -9
- package/dist/cjs/shared/getPageContextUrlComputed.js +43 -37
- package/dist/cjs/shared/modifyUrl.js +31 -0
- package/dist/cjs/shared/route/abort.js +4 -10
- package/dist/cjs/shared/route/executeOnBeforeRouteHook.js +3 -1
- package/dist/cjs/utils/parseUrl.js +168 -87
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/cjs/utils/redirectHard.js +7 -0
- package/dist/cjs/utils/urlToFile.js +1 -1
- package/dist/esm/client/client-routing-runtime/createPageContext.d.ts +1 -1
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +2 -2
- package/dist/esm/client/client-routing-runtime/navigate.js +2 -1
- package/dist/esm/client/client-routing-runtime/prefetch.js +5 -4
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +23 -21
- package/dist/esm/client/client-routing-runtime/skipLink.js +11 -22
- package/dist/esm/client/client-routing-runtime/utils.d.ts +1 -2
- package/dist/esm/client/client-routing-runtime/utils.js +1 -2
- package/dist/esm/node/plugin/plugins/envVars.d.ts +0 -2
- package/dist/esm/node/plugin/plugins/envVars.js +6 -12
- package/dist/esm/node/runtime/renderPage/createHttpResponseObject/assertNoInfiniteHttpRedirect.js +2 -3
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +5 -5
- package/dist/esm/{shared/route → node/runtime/renderPage}/resolveRedirects.js +9 -11
- package/dist/esm/node/runtime/renderPage.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage.js +7 -10
- package/dist/esm/shared/getPageContextUrlComputed.d.ts +2 -24
- package/dist/esm/shared/getPageContextUrlComputed.js +43 -37
- package/dist/esm/shared/modifyUrl.d.ts +14 -0
- package/dist/esm/shared/modifyUrl.js +28 -0
- package/dist/esm/shared/route/abort.js +5 -11
- package/dist/esm/shared/route/executeOnBeforeRouteHook.js +4 -2
- package/dist/esm/types/index.d.ts +1 -1
- package/dist/esm/utils/parseUrl.d.ts +43 -10
- package/dist/esm/utils/parseUrl.js +167 -86
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/dist/esm/utils/redirectHard.d.ts +1 -0
- package/dist/esm/utils/redirectHard.js +3 -0
- package/dist/esm/utils/urlToFile.js +1 -1
- package/package.json +17 -2
- package/dist/cjs/utils/isExternalLink.js +0 -7
- package/dist/cjs/utils/serverSideRouteTo.js +0 -7
- package/dist/esm/utils/isExternalLink.d.ts +0 -2
- package/dist/esm/utils/isExternalLink.js +0 -4
- package/dist/esm/utils/serverSideRouteTo.d.ts +0 -2
- package/dist/esm/utils/serverSideRouteTo.js +0 -4
- /package/dist/esm/{shared/route → node/runtime/renderPage}/resolveRedirects.d.ts +0 -0
|
@@ -3,38 +3,21 @@
|
|
|
3
3
|
// - It doesn't support the tauri:// protocol
|
|
4
4
|
// Unit tests at ./parseUrl.spec.ts
|
|
5
5
|
export { parseUrl };
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
6
|
+
export { assertUsageUrlPathname };
|
|
7
|
+
export { assertUsageUrlPathnameAbsolute };
|
|
8
|
+
export { assertUsageUrlRedirectTarget };
|
|
9
|
+
export { isUrl };
|
|
10
|
+
export { isUri };
|
|
11
|
+
export { isUrlRedirectTarget };
|
|
12
|
+
export { isUrlExternal };
|
|
8
13
|
export { isBaseServer };
|
|
9
14
|
export { assertUrlComponents };
|
|
10
15
|
export { createUrlFromComponents };
|
|
11
|
-
export { isUriWithProtocol };
|
|
12
16
|
import { slice } from './slice.js';
|
|
13
17
|
import { assert, assertUsage } from './assert.js';
|
|
14
18
|
import pc from '@brillout/picocolors';
|
|
15
|
-
function isParsable(url) {
|
|
16
|
-
// `parseUrl()` works with these URLs
|
|
17
|
-
return (isUrlWithProtocol(url) ||
|
|
18
|
-
url.startsWith('/') ||
|
|
19
|
-
url.startsWith('.') ||
|
|
20
|
-
url.startsWith('?') ||
|
|
21
|
-
url.startsWith('#') ||
|
|
22
|
-
url === '');
|
|
23
|
-
}
|
|
24
|
-
function assertUsageUrl(url, errPrefix) {
|
|
25
|
-
assert(errPrefix.includes(' but '));
|
|
26
|
-
assertUsage(typeof url === 'string', `${errPrefix} should be a string`);
|
|
27
|
-
if (isParsable(url))
|
|
28
|
-
return;
|
|
29
|
-
if (!url.startsWith('/') && !url.includes(':')) {
|
|
30
|
-
assertUsage(false, `${errPrefix} is ${pc.cyan(url)} and it should be /${pc.cyan(url)} instead (URL pathnames should start with a leading slash)`);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
assertUsage(false, `${errPrefix} isn't a valid URL`);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
19
|
function parseUrl(url, baseServer) {
|
|
37
|
-
assert(
|
|
20
|
+
assert(isUrl(url), url);
|
|
38
21
|
assert(baseServer.startsWith('/'));
|
|
39
22
|
// Hash
|
|
40
23
|
const [urlWithoutHash, ...hashList] = url.split('#');
|
|
@@ -54,18 +37,24 @@ function parseUrl(url, baseServer) {
|
|
|
54
37
|
searchAll[key] = [...(searchAll.hasOwnProperty(key) ? searchAll[key] : []), val];
|
|
55
38
|
});
|
|
56
39
|
// Origin + pathname
|
|
57
|
-
|
|
58
|
-
assert(origin === null || origin === decodeSafe(origin)); // AFAICT decoding the origin is useless
|
|
59
|
-
assert(pathnameResolved.startsWith('/'));
|
|
60
|
-
assert(origin === null || url.startsWith(origin));
|
|
61
|
-
// `pathnameOriginal`
|
|
40
|
+
let { protocol, origin, pathnameAbsoluteWithBase } = getPathnameAbsoluteWithBase(urlWithoutHashNorSearch, baseServer);
|
|
62
41
|
const pathnameOriginal = urlWithoutHashNorSearch.slice((origin || '').length);
|
|
63
42
|
assertUrlComponents(url, origin, pathnameOriginal, searchOriginal, hashOriginal);
|
|
64
43
|
// Base URL
|
|
65
|
-
let { pathname, hasBaseServer } =
|
|
44
|
+
let { pathname, hasBaseServer } = removeBaseServer(pathnameAbsoluteWithBase, baseServer);
|
|
45
|
+
// pageContext.urlParsed.href
|
|
46
|
+
const href = createUrlFromComponents(origin, pathname, searchOriginal, hashOriginal);
|
|
47
|
+
// pageContext.urlParsed.{hostname, port}
|
|
48
|
+
const host = !origin ? null : origin.slice(protocol.length);
|
|
49
|
+
const { hostname, port } = parseHost(host, url);
|
|
50
|
+
// decode after setting href
|
|
66
51
|
pathname = decodePathname(pathname);
|
|
67
52
|
assert(pathname.startsWith('/'));
|
|
68
53
|
return {
|
|
54
|
+
href,
|
|
55
|
+
protocol,
|
|
56
|
+
hostname,
|
|
57
|
+
port,
|
|
69
58
|
origin,
|
|
70
59
|
pathname,
|
|
71
60
|
pathnameOriginal: pathnameOriginal,
|
|
@@ -96,20 +85,20 @@ function decodePathname(urlPathname) {
|
|
|
96
85
|
.join('/');
|
|
97
86
|
return urlPathname;
|
|
98
87
|
}
|
|
99
|
-
function
|
|
88
|
+
function getPathnameAbsoluteWithBase(url, baseServer) {
|
|
100
89
|
// Search and hash already extracted
|
|
101
90
|
assert(!url.includes('?') && !url.includes('#'));
|
|
102
91
|
// url has origin
|
|
103
92
|
{
|
|
104
|
-
const { origin, pathname } = parseOrigin(url);
|
|
93
|
+
const { protocol, origin, pathname } = parseOrigin(url);
|
|
105
94
|
if (origin) {
|
|
106
|
-
return { origin, pathname };
|
|
95
|
+
return { protocol, origin, pathnameAbsoluteWithBase: pathname };
|
|
107
96
|
}
|
|
108
97
|
assert(pathname === url);
|
|
109
98
|
}
|
|
110
99
|
// url doesn't have origin
|
|
111
100
|
if (url.startsWith('/')) {
|
|
112
|
-
return { origin: null,
|
|
101
|
+
return { protocol: null, origin: null, pathnameAbsoluteWithBase: url };
|
|
113
102
|
}
|
|
114
103
|
else {
|
|
115
104
|
// url is a relative path
|
|
@@ -124,21 +113,70 @@ function getPathname(url, baseServer) {
|
|
|
124
113
|
else {
|
|
125
114
|
base = baseServer;
|
|
126
115
|
}
|
|
127
|
-
const
|
|
128
|
-
return { origin: null,
|
|
116
|
+
const pathnameAbsoluteWithBase = resolveUrlPathnameRelative(url, base);
|
|
117
|
+
return { protocol: null, origin: null, pathnameAbsoluteWithBase: pathnameAbsoluteWithBase };
|
|
129
118
|
}
|
|
130
119
|
}
|
|
131
120
|
function parseOrigin(url) {
|
|
132
121
|
if (!isUrlWithProtocol(url)) {
|
|
133
|
-
|
|
134
|
-
return { pathname: url, origin: null };
|
|
122
|
+
return { pathname: url, origin: null, protocol: null };
|
|
135
123
|
}
|
|
136
124
|
else {
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
|
|
125
|
+
const { protocol, uriWithoutProtocol } = parseProtocol(url);
|
|
126
|
+
assert(protocol);
|
|
127
|
+
const [host, ...rest] = uriWithoutProtocol.split('/');
|
|
128
|
+
const origin = protocol + host;
|
|
129
|
+
const pathname = '/' + rest.join('/');
|
|
130
|
+
return { pathname, origin, protocol };
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function parseHost(host, url) {
|
|
134
|
+
const ret = { hostname: null, port: null };
|
|
135
|
+
if (!host)
|
|
136
|
+
return ret;
|
|
137
|
+
// hostname
|
|
138
|
+
const [hostname, ...rest] = host.split(':');
|
|
139
|
+
ret.hostname = hostname;
|
|
140
|
+
// port
|
|
141
|
+
if (rest.length > 0) {
|
|
142
|
+
assert(rest.length === 1, url);
|
|
143
|
+
const portStr = rest[0];
|
|
144
|
+
const port = parseInt(portStr, 10);
|
|
145
|
+
assert(port || port === 0, url);
|
|
146
|
+
ret.port = port;
|
|
141
147
|
}
|
|
148
|
+
return ret;
|
|
149
|
+
}
|
|
150
|
+
function parseProtocol(uri) {
|
|
151
|
+
const SEP = ':';
|
|
152
|
+
const [before, ...after] = uri.split(SEP);
|
|
153
|
+
if (after.length === 0 ||
|
|
154
|
+
// https://github.com/vikejs/vike/commit/886a99ff21e86a8ca699a25cee7edc184aa058e4#r143308934
|
|
155
|
+
// https://en.wikipedia.org/wiki/List_of_URI_schemes
|
|
156
|
+
// https://www.rfc-editor.org/rfc/rfc7595
|
|
157
|
+
!/^[a-z][a-z0-9\+\-]*$/i.test(before)) {
|
|
158
|
+
return { protocol: null, uriWithoutProtocol: uri };
|
|
159
|
+
}
|
|
160
|
+
let protocol = before + SEP;
|
|
161
|
+
let uriWithoutProtocol = after.join(SEP);
|
|
162
|
+
const SEP2 = '//';
|
|
163
|
+
if (uriWithoutProtocol.startsWith(SEP2)) {
|
|
164
|
+
protocol = protocol + SEP2;
|
|
165
|
+
uriWithoutProtocol = uriWithoutProtocol.slice(SEP2.length);
|
|
166
|
+
}
|
|
167
|
+
return { protocol, uriWithoutProtocol };
|
|
168
|
+
}
|
|
169
|
+
function isUrlProtocol(protocol) {
|
|
170
|
+
// Is there an altenrative to having a blacklist?
|
|
171
|
+
// - If the blacklist becomes too big, maybe use a whitelist instead ['tauri://', 'file://', 'capacitor://', 'http://', 'https://']
|
|
172
|
+
const blacklist = [
|
|
173
|
+
// https://docs.ipfs.tech/how-to/address-ipfs-on-web
|
|
174
|
+
'ipfs://',
|
|
175
|
+
'ipns://'
|
|
176
|
+
];
|
|
177
|
+
if (blacklist.includes(protocol))
|
|
178
|
+
return false;
|
|
179
|
+
return protocol.endsWith('://');
|
|
142
180
|
}
|
|
143
181
|
// Adapted from https://stackoverflow.com/questions/14780350/convert-relative-path-to-absolute-using-javascript/14780463#14780463
|
|
144
182
|
function resolveUrlPathnameRelative(pathnameRelative, base) {
|
|
@@ -169,34 +207,15 @@ function resolveUrlPathnameRelative(pathnameRelative, base) {
|
|
|
169
207
|
pathnameAbsolute = '/' + pathnameAbsolute;
|
|
170
208
|
return pathnameAbsolute;
|
|
171
209
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
assertUsage(
|
|
175
|
-
!baseServer.startsWith('http'),
|
|
176
|
-
usageErrorMessagePrefix +
|
|
177
|
-
'`base` is not allowed to start with `http`. Consider using `baseAssets` instead, see https://vike.dev/base-url'
|
|
178
|
-
)
|
|
179
|
-
assertUsage(
|
|
180
|
-
baseServer.startsWith('/'),
|
|
181
|
-
usageErrorMessagePrefix + 'Wrong `base` value `' + baseServer + '`; `base` should start with `/`.'
|
|
182
|
-
)
|
|
183
|
-
assert(isBaseServer(baseServer))
|
|
184
|
-
}
|
|
185
|
-
*/
|
|
186
|
-
function assertPathname(urlPathname) {
|
|
187
|
-
assert(urlPathname.startsWith('/'));
|
|
188
|
-
assert(!urlPathname.includes('?'));
|
|
189
|
-
assert(!urlPathname.includes('#'));
|
|
190
|
-
}
|
|
191
|
-
function analyzeBaseServer(urlPathnameWithBase, baseServer) {
|
|
192
|
-
assertPathname(urlPathnameWithBase);
|
|
210
|
+
function removeBaseServer(pathnameAbsoluteWithBase, baseServer) {
|
|
211
|
+
assert(pathnameAbsoluteWithBase.startsWith('/'));
|
|
193
212
|
assert(isBaseServer(baseServer));
|
|
194
213
|
// Mutable
|
|
195
|
-
let urlPathname =
|
|
214
|
+
let urlPathname = pathnameAbsoluteWithBase;
|
|
196
215
|
assert(urlPathname.startsWith('/'));
|
|
197
216
|
assert(baseServer.startsWith('/'));
|
|
198
217
|
if (baseServer === '/') {
|
|
199
|
-
const pathname =
|
|
218
|
+
const pathname = pathnameAbsoluteWithBase;
|
|
200
219
|
return { pathname, hasBaseServer: true };
|
|
201
220
|
}
|
|
202
221
|
// Support `url === '/some-base-url' && baseServer === '/some-base-url/'`
|
|
@@ -206,7 +225,7 @@ function analyzeBaseServer(urlPathnameWithBase, baseServer) {
|
|
|
206
225
|
assert(urlPathname === baseServerNormalized);
|
|
207
226
|
}
|
|
208
227
|
if (!urlPathname.startsWith(baseServerNormalized)) {
|
|
209
|
-
const pathname =
|
|
228
|
+
const pathname = pathnameAbsoluteWithBase;
|
|
210
229
|
return { pathname, hasBaseServer: false };
|
|
211
230
|
}
|
|
212
231
|
assert(urlPathname.startsWith('/') || urlPathname.startsWith('http'));
|
|
@@ -220,27 +239,89 @@ function analyzeBaseServer(urlPathnameWithBase, baseServer) {
|
|
|
220
239
|
function isBaseServer(baseServer) {
|
|
221
240
|
return baseServer.startsWith('/');
|
|
222
241
|
}
|
|
223
|
-
function assertUrlComponents(url, origin,
|
|
224
|
-
const urlRecreated = createUrlFromComponents(origin,
|
|
242
|
+
function assertUrlComponents(url, origin, pathnameOriginal, searchOriginal, hashOriginal) {
|
|
243
|
+
const urlRecreated = createUrlFromComponents(origin, pathnameOriginal, searchOriginal, hashOriginal);
|
|
225
244
|
assert(url === urlRecreated);
|
|
226
245
|
}
|
|
227
|
-
function createUrlFromComponents(origin, pathname,
|
|
228
|
-
const urlRecreated = `${origin || ''}${pathname}${
|
|
246
|
+
function createUrlFromComponents(origin, pathname, search, hash) {
|
|
247
|
+
const urlRecreated = `${origin || ''}${pathname}${search || ''}${hash || ''}`;
|
|
229
248
|
return urlRecreated;
|
|
230
249
|
}
|
|
231
|
-
function
|
|
232
|
-
//
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
250
|
+
function isUrl(url) {
|
|
251
|
+
// parseUrl() works with these URLs
|
|
252
|
+
return isUrlWithProtocol(url) || url.startsWith('/') || isUrlPathnameRelative(url);
|
|
253
|
+
}
|
|
254
|
+
function isUrlRedirectTarget(url) {
|
|
255
|
+
return url.startsWith('/') || isUri(url) || isUrlWithProtocol(url);
|
|
256
|
+
}
|
|
257
|
+
function isUrlPathnameRelative(url) {
|
|
258
|
+
return ['.', '?', '#'].some((c) => url.startsWith(c)) || url === '';
|
|
259
|
+
}
|
|
260
|
+
function isUrlExternal(url) {
|
|
261
|
+
return !url.startsWith('/') && !isUrlPathnameRelative(url);
|
|
262
|
+
}
|
|
263
|
+
/*
|
|
264
|
+
URL with protocol.
|
|
265
|
+
|
|
266
|
+
http://example.com
|
|
267
|
+
https://exmaple.com
|
|
268
|
+
tauri://localhost
|
|
269
|
+
file://example.com
|
|
270
|
+
capacitor://localhost/assets/chunks/chunk-DJBYDrsP.js
|
|
271
|
+
|
|
272
|
+
[Tauri](https://github.com/vikejs/vike/issues/808)
|
|
273
|
+
[Electron (`file://`)](https://github.com/vikejs/vike/issues/1557)
|
|
274
|
+
[Capacitor](https://github.com/vikejs/vike/issues/1706)
|
|
275
|
+
*/
|
|
276
|
+
function isUrlWithProtocol(url) {
|
|
277
|
+
const { protocol } = parseProtocol(url);
|
|
278
|
+
return !!protocol && isUrlProtocol(protocol);
|
|
279
|
+
}
|
|
280
|
+
/*
|
|
281
|
+
URIs that aren't URLs.
|
|
282
|
+
|
|
283
|
+
mailto:john@example.com
|
|
284
|
+
|
|
285
|
+
ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/wiki/Vincent_van_Gogh.html
|
|
286
|
+
|
|
287
|
+
magnet:?xt=urn:btih:3a15e1ac49683d91b20c2ffc252ea612a6c01bd7&dn=The.Empire.Strikes.Back.1980.Remastered.1080p.BluRay.DDP.7.1.x265-EDGE2020.mkv&xl=3225443573&tr=udp://tracker.opentrackr.org:1337/announce&tr=udp://tracker.torrent.eu.org:451&tr=udp://open.stealth.si:80/announce&tr=udp://tracker.openbittorrent.com:6969&tr=udp://tracker.tiny-vps.com:6969/announce&tr=udp://open.demonii.com:1337
|
|
288
|
+
|
|
289
|
+
We need to treat URIs differently than URLs.
|
|
290
|
+
- For example, we cannot parse URIs (their structure is unknown e.g. a `magnet:` URI is completely different than a `http://` URL).
|
|
291
|
+
- The protocols tauri:// file:// capacitor:// follow the same structure as http:// and https:// URLs.
|
|
292
|
+
- Thus we can parse them like http:// and https:// URLs.
|
|
293
|
+
*/
|
|
294
|
+
function isUri(uri) {
|
|
295
|
+
const { protocol } = parseProtocol(uri);
|
|
296
|
+
return !!protocol && !isUrlProtocol(uri);
|
|
297
|
+
}
|
|
298
|
+
function assertUsageUrlPathname(url, errPrefix) {
|
|
299
|
+
assertUsageUrl(url, errPrefix, { allowRelative: true });
|
|
300
|
+
}
|
|
301
|
+
function assertUsageUrlPathnameAbsolute(url, errPrefix) {
|
|
302
|
+
assertUsageUrl(url, errPrefix);
|
|
303
|
+
}
|
|
304
|
+
function assertUsageUrlRedirectTarget(url, errPrefix, isUnresolved) {
|
|
305
|
+
assertUsageUrl(url, errPrefix, { isRedirectTarget: isUnresolved ? 'unresolved' : true });
|
|
306
|
+
}
|
|
307
|
+
function assertUsageUrl(url, errPrefix, { allowRelative, isRedirectTarget } = {}) {
|
|
308
|
+
if (url.startsWith('/'))
|
|
309
|
+
return;
|
|
310
|
+
let errMsg = `${errPrefix} is ${pc.string(url)} but it should start with ${pc.string('/')}`;
|
|
311
|
+
if (isRedirectTarget) {
|
|
312
|
+
if (isUrlRedirectTarget(url))
|
|
313
|
+
return;
|
|
314
|
+
errMsg += ` or a protocol (${pc.string('http://')}, ${pc.string('mailto:')}, ...)`;
|
|
315
|
+
if (isRedirectTarget === 'unresolved') {
|
|
316
|
+
if (url === '*')
|
|
317
|
+
return;
|
|
318
|
+
errMsg += `, or be ${pc.string('*')}`;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
if (allowRelative) {
|
|
322
|
+
if (isUrlPathnameRelative(url))
|
|
323
|
+
return;
|
|
324
|
+
errMsg += ', or be a relative URL';
|
|
325
|
+
}
|
|
326
|
+
assertUsage(false, errMsg);
|
|
246
327
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { projectInfo };
|
|
2
2
|
export { PROJECT_VERSION };
|
|
3
|
-
declare const PROJECT_VERSION: "0.4.
|
|
3
|
+
declare const PROJECT_VERSION: "0.4.181-commit-ee50efa";
|
|
4
4
|
declare const projectInfo: {
|
|
5
5
|
projectName: "Vike";
|
|
6
|
-
projectVersion: "0.4.
|
|
6
|
+
projectVersion: "0.4.181-commit-ee50efa";
|
|
7
7
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function redirectHard(url: string): void;
|
|
@@ -4,7 +4,7 @@ import { assert } from './assert.js';
|
|
|
4
4
|
import { parseUrl } from './parseUrl.js';
|
|
5
5
|
import { slice } from './slice.js';
|
|
6
6
|
// - When doing a `.pageContext.json` HTTP request, the base URL should be preserved. (The server-side will handle the base URL.)
|
|
7
|
-
// - While
|
|
7
|
+
// - While pre-rendering there is no base URL
|
|
8
8
|
const baseServer = '/';
|
|
9
9
|
function urlToFile(url, fileExtension, doNotCreateExtraDirectory) {
|
|
10
10
|
const { pathnameOriginal, searchOriginal, hashOriginal } = parseUrl(url, baseServer);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.181-commit-ee50efa",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "tsc --watch",
|
|
6
6
|
"build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@brillout/import": "^0.2.3",
|
|
17
17
|
"@brillout/json-serializer": "^0.5.13",
|
|
18
|
-
"@brillout/picocolors": "^1.0.
|
|
18
|
+
"@brillout/picocolors": "^1.0.14",
|
|
19
19
|
"@brillout/require-shim": "^0.1.2",
|
|
20
20
|
"@brillout/vite-plugin-server-entry": "^0.4.5",
|
|
21
21
|
"acorn": "^8.0.0",
|
|
@@ -116,6 +116,15 @@
|
|
|
116
116
|
"types": "./dist/esm/shared/getPageContext.d.ts",
|
|
117
117
|
"default": "./dist/esm/shared/getPageContext.js"
|
|
118
118
|
},
|
|
119
|
+
"./modifyUrl": {
|
|
120
|
+
"worker": "./dist/esm/shared/modifyUrl.js",
|
|
121
|
+
"edge-light": "./dist/esm/shared/modifyUrl.js",
|
|
122
|
+
"require": "./dist/cjs/shared/modifyUrl.js",
|
|
123
|
+
"node": "./dist/esm/shared/modifyUrl.js",
|
|
124
|
+
"browser": "./dist/esm/shared/modifyUrl.js",
|
|
125
|
+
"types": "./dist/esm/shared/modifyUrl.d.ts",
|
|
126
|
+
"default": "./dist/esm/shared/modifyUrl.js"
|
|
127
|
+
},
|
|
119
128
|
"./__internal": {
|
|
120
129
|
"require": "./dist/cjs/__internal/index.js",
|
|
121
130
|
"node": "./dist/esm/__internal/index.js",
|
|
@@ -180,6 +189,12 @@
|
|
|
180
189
|
"abort": [
|
|
181
190
|
"./dist/esm/shared/abort.d.ts"
|
|
182
191
|
],
|
|
192
|
+
"getPageContext": [
|
|
193
|
+
"./dist/esm/shared/getPageContext.d.ts"
|
|
194
|
+
],
|
|
195
|
+
"modifyUrl": [
|
|
196
|
+
"./dist/esm/shared/modifyUrl.d.ts"
|
|
197
|
+
],
|
|
183
198
|
"__internal": [
|
|
184
199
|
"./dist/esm/__internal/index.d.ts"
|
|
185
200
|
],
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isExternalLink = void 0;
|
|
4
|
-
function isExternalLink(url) {
|
|
5
|
-
return !url.startsWith('/') && !url.startsWith('.') && !url.startsWith('?') && url !== '';
|
|
6
|
-
}
|
|
7
|
-
exports.isExternalLink = isExternalLink;
|
|
File without changes
|