@jk2908/solas 0.8.2 → 0.8.3
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/CHANGELOG.md +6 -0
- package/dist/index.js +20 -1
- package/dist/types.d.ts +3 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.8.3
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- `url` and `trustedOrigins` now accept plain strings, so `process.env` values can be passed directly without a cast. The resolved `url` is validated (it must be an `http(s)` origin) and normalised to its origin.
|
|
8
|
+
|
|
3
9
|
## 0.8.2
|
|
4
10
|
|
|
5
11
|
### Fixes
|
package/dist/index.js
CHANGED
|
@@ -22,6 +22,25 @@ const DEFAULT_CONFIG = {
|
|
|
22
22
|
trustedOrigins: [],
|
|
23
23
|
trailingSlash: 'never',
|
|
24
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* Validate a configured url and return its canonical origin (scheme and host,
|
|
27
|
+
* without a trailing slash or path). Throws when it is not a http(s) origin.
|
|
28
|
+
*/
|
|
29
|
+
function resolveOrigin(value) {
|
|
30
|
+
if (!value)
|
|
31
|
+
return undefined;
|
|
32
|
+
let url;
|
|
33
|
+
try {
|
|
34
|
+
url = new URL(value);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
throw new Error(`[solas] Invalid url: "${value}"`);
|
|
38
|
+
}
|
|
39
|
+
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
|
|
40
|
+
throw new Error(`[solas] url must use http:// or https://: "${value}"`);
|
|
41
|
+
}
|
|
42
|
+
return url.origin;
|
|
43
|
+
}
|
|
25
44
|
function solas(c) {
|
|
26
45
|
const validatedConfig = Config.validate(c);
|
|
27
46
|
const config = {
|
|
@@ -29,7 +48,7 @@ function solas(c) {
|
|
|
29
48
|
...validatedConfig,
|
|
30
49
|
};
|
|
31
50
|
const envUrl = process.env.VITE_APP_URL?.toString();
|
|
32
|
-
let resolvedUrl = c?.url ?? (envUrl
|
|
51
|
+
let resolvedUrl = resolveOrigin(c?.url) ?? resolveOrigin(envUrl);
|
|
33
52
|
if (config.logger?.level)
|
|
34
53
|
Logger.defaultLevel = config.logger.level;
|
|
35
54
|
const logger = new Logger();
|
package/dist/types.d.ts
CHANGED
|
@@ -25,14 +25,14 @@ type PluginConfigBase = {
|
|
|
25
25
|
prerender?: Route.Prerender;
|
|
26
26
|
metadata?: Metadata.Item;
|
|
27
27
|
trailingSlash?: (typeof Config.TRAILING_SLASH_MODES)[number];
|
|
28
|
-
trustedOrigins?: readonly
|
|
28
|
+
trustedOrigins?: readonly string[];
|
|
29
29
|
adapter?: Adapter;
|
|
30
30
|
readonly logger?: {
|
|
31
31
|
level?: LogLevel;
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
34
|
export type PluginConfig = PluginConfigBase & {
|
|
35
|
-
url?:
|
|
35
|
+
url?: string;
|
|
36
36
|
sitemap?: boolean | {
|
|
37
37
|
routes: (existing: string[]) => string[] | Promise<string[]>;
|
|
38
38
|
};
|
|
@@ -116,7 +116,7 @@ export type BuildManifest = {
|
|
|
116
116
|
sitemapRoutes: string[];
|
|
117
117
|
precompress: boolean;
|
|
118
118
|
trailingSlash: (typeof Config.TRAILING_SLASH_MODES)[number];
|
|
119
|
-
url?:
|
|
119
|
+
url?: string;
|
|
120
120
|
};
|
|
121
121
|
export declare namespace Route {
|
|
122
122
|
type ParamsOf<TRoute> = TRoute extends {
|
package/package.json
CHANGED