@tryghost/url-utils 5.0.0 → 5.1.0
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/lib/UrlUtils.d.ts +147 -3
- package/lib/UrlUtils.js +228 -112
- package/lib/index.d.ts +2 -0
- package/lib/index.js +6 -0
- package/lib/utils/absolute-to-relative.d.ts +9 -3
- package/lib/utils/absolute-to-relative.js +13 -8
- package/lib/utils/absolute-to-transform-ready.d.ts +13 -4
- package/lib/utils/absolute-to-transform-ready.js +15 -10
- package/lib/utils/build-early-exit-match.d.ts +11 -1
- package/lib/utils/build-early-exit-match.js +4 -4
- package/lib/utils/deduplicate-double-slashes.d.ts +2 -1
- package/lib/utils/deduplicate-double-slashes.js +2 -2
- package/lib/utils/deduplicate-subdirectory.d.ts +2 -2
- package/lib/utils/deduplicate-subdirectory.js +4 -4
- package/lib/utils/html-absolute-to-relative.d.ts +3 -3
- package/lib/utils/html-absolute-to-relative.js +10 -7
- package/lib/utils/html-absolute-to-transform-ready.d.ts +3 -4
- package/lib/utils/html-absolute-to-transform-ready.js +16 -9
- package/lib/utils/html-relative-to-absolute.d.ts +3 -3
- package/lib/utils/html-relative-to-absolute.js +9 -6
- package/lib/utils/html-relative-to-transform-ready.d.ts +3 -3
- package/lib/utils/html-relative-to-transform-ready.js +17 -9
- package/lib/utils/html-to-transform-ready.d.ts +3 -3
- package/lib/utils/html-to-transform-ready.js +17 -9
- package/lib/utils/html-transform.d.ts +3 -4
- package/lib/utils/html-transform.js +18 -19
- package/lib/utils/index.d.ts +76 -0
- package/lib/utils/index.js +115 -38
- package/lib/utils/is-ssl.d.ts +2 -2
- package/lib/utils/is-ssl.js +4 -4
- package/lib/utils/lexical-absolute-to-relative.d.ts +3 -2
- package/lib/utils/lexical-absolute-to-relative.js +9 -6
- package/lib/utils/lexical-absolute-to-transform-ready.d.ts +3 -2
- package/lib/utils/lexical-absolute-to-transform-ready.js +10 -7
- package/lib/utils/lexical-relative-to-absolute.d.ts +3 -3
- package/lib/utils/lexical-relative-to-absolute.js +8 -5
- package/lib/utils/lexical-relative-to-transform-ready.d.ts +3 -3
- package/lib/utils/lexical-relative-to-transform-ready.js +8 -5
- package/lib/utils/lexical-to-transform-ready.d.ts +3 -3
- package/lib/utils/lexical-to-transform-ready.js +17 -9
- package/lib/utils/lexical-transform.d.ts +3 -2
- package/lib/utils/lexical-transform.js +21 -19
- package/lib/utils/markdown-absolute-to-relative.d.ts +3 -4
- package/lib/utils/markdown-absolute-to-relative.js +11 -8
- package/lib/utils/markdown-absolute-to-transform-ready.d.ts +3 -5
- package/lib/utils/markdown-absolute-to-transform-ready.js +17 -10
- package/lib/utils/markdown-relative-to-absolute.d.ts +3 -4
- package/lib/utils/markdown-relative-to-absolute.js +11 -8
- package/lib/utils/markdown-relative-to-transform-ready.d.ts +3 -4
- package/lib/utils/markdown-relative-to-transform-ready.js +11 -8
- package/lib/utils/markdown-to-transform-ready.d.ts +3 -3
- package/lib/utils/markdown-to-transform-ready.js +17 -9
- package/lib/utils/markdown-transform.d.ts +3 -5
- package/lib/utils/markdown-transform.js +9 -6
- package/lib/utils/mobiledoc-absolute-to-relative.d.ts +3 -2
- package/lib/utils/mobiledoc-absolute-to-relative.js +9 -6
- package/lib/utils/mobiledoc-absolute-to-transform-ready.d.ts +3 -2
- package/lib/utils/mobiledoc-absolute-to-transform-ready.js +10 -7
- package/lib/utils/mobiledoc-relative-to-absolute.d.ts +3 -3
- package/lib/utils/mobiledoc-relative-to-absolute.js +8 -5
- package/lib/utils/mobiledoc-relative-to-transform-ready.d.ts +3 -3
- package/lib/utils/mobiledoc-relative-to-transform-ready.js +8 -5
- package/lib/utils/mobiledoc-to-transform-ready.d.ts +3 -3
- package/lib/utils/mobiledoc-to-transform-ready.js +17 -9
- package/lib/utils/mobiledoc-transform.d.ts +3 -1
- package/lib/utils/mobiledoc-transform.js +5 -4
- package/lib/utils/plaintext-absolute-to-transform-ready.d.ts +5 -4
- package/lib/utils/plaintext-absolute-to-transform-ready.js +16 -11
- package/lib/utils/plaintext-relative-to-transform-ready.d.ts +3 -2
- package/lib/utils/plaintext-relative-to-transform-ready.js +15 -7
- package/lib/utils/plaintext-to-transform-ready.d.ts +5 -3
- package/lib/utils/plaintext-to-transform-ready.js +17 -9
- package/lib/utils/relative-to-absolute.d.ts +5 -3
- package/lib/utils/relative-to-absolute.js +25 -18
- package/lib/utils/relative-to-transform-ready.d.ts +8 -2
- package/lib/utils/relative-to-transform-ready.js +22 -10
- package/lib/utils/replace-permalink.d.ts +13 -2
- package/lib/utils/replace-permalink.js +44 -8
- package/lib/utils/strip-subdirectory-from-path.d.ts +1 -1
- package/lib/utils/strip-subdirectory-from-path.js +4 -4
- package/lib/utils/to-transform-ready.d.ts +5 -3
- package/lib/utils/to-transform-ready.js +17 -9
- package/lib/utils/transform-ready-to-absolute.d.ts +9 -1
- package/lib/utils/transform-ready-to-absolute.js +2 -2
- package/lib/utils/transform-ready-to-relative.d.ts +3 -1
- package/lib/utils/transform-ready-to-relative.js +4 -3
- package/lib/utils/types.d.ts +92 -0
- package/lib/utils/types.js +2 -0
- package/lib/utils/url-join.d.ts +5 -2
- package/lib/utils/url-join.js +11 -5
- package/package.json +8 -9
- package/index.js +0 -2
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
interface PermalinkResource {
|
|
2
|
+
published_at?: string | number | Date | null;
|
|
3
|
+
primary_author?: {
|
|
4
|
+
slug: string;
|
|
5
|
+
} | null;
|
|
6
|
+
primary_tag?: {
|
|
7
|
+
slug: string;
|
|
8
|
+
} | null;
|
|
9
|
+
slug: string;
|
|
10
|
+
id: string;
|
|
11
|
+
}
|
|
2
12
|
/**
|
|
3
13
|
* creates the url path for a post based on blog timezone and permalink pattern
|
|
4
14
|
*/
|
|
5
|
-
declare function replacePermalink(permalink:
|
|
15
|
+
declare function replacePermalink(permalink: string, resource: PermalinkResource, timezone?: string): string;
|
|
16
|
+
export default replacePermalink;
|
|
@@ -1,11 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const moment = __importStar(require("moment-timezone"));
|
|
4
37
|
/**
|
|
5
38
|
* creates the url path for a post based on blog timezone and permalink pattern
|
|
6
39
|
*/
|
|
7
40
|
function replacePermalink(permalink, resource, timezone = 'UTC') {
|
|
8
|
-
const output = permalink;
|
|
9
41
|
const primaryTagFallback = 'all';
|
|
10
42
|
const publishedAtMoment = moment.tz(resource.published_at || Date.now(), timezone);
|
|
11
43
|
const permalinkLookUp = {
|
|
@@ -19,7 +51,7 @@ function replacePermalink(permalink, resource, timezone = 'UTC') {
|
|
|
19
51
|
return publishedAtMoment.format('DD');
|
|
20
52
|
},
|
|
21
53
|
author: function () {
|
|
22
|
-
return resource.primary_author
|
|
54
|
+
return resource.primary_author?.slug ?? 'undefined';
|
|
23
55
|
},
|
|
24
56
|
primary_author: function () {
|
|
25
57
|
return resource.primary_author ? resource.primary_author.slug : primaryTagFallback;
|
|
@@ -36,10 +68,14 @@ function replacePermalink(permalink, resource, timezone = 'UTC') {
|
|
|
36
68
|
};
|
|
37
69
|
// replace tags like :slug or :year with actual values
|
|
38
70
|
const permalinkKeys = Object.keys(permalinkLookUp);
|
|
39
|
-
return
|
|
40
|
-
|
|
41
|
-
|
|
71
|
+
return permalink.replace(/(:[a-z_]+)/g, function (match) {
|
|
72
|
+
const key = match.slice(1);
|
|
73
|
+
if (permalinkKeys.includes(key)) {
|
|
74
|
+
// Known route segment - use the lookup function
|
|
75
|
+
return permalinkLookUp[key]();
|
|
42
76
|
}
|
|
77
|
+
// Unknown route segment - return 'undefined' string
|
|
78
|
+
return 'undefined';
|
|
43
79
|
});
|
|
44
80
|
}
|
|
45
|
-
|
|
81
|
+
exports.default = replacePermalink;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
declare const URL: any;
|
|
2
1
|
/**
|
|
3
2
|
* Removes the directory in the root url from the relative path
|
|
4
3
|
*
|
|
@@ -7,3 +6,4 @@ declare const URL: any;
|
|
|
7
6
|
* @returns {string} Path relative to the rootUrl's path
|
|
8
7
|
*/
|
|
9
8
|
declare const stripSubdirectoryFromPath: (path?: string, rootUrl?: string) => string;
|
|
9
|
+
export default stripSubdirectoryFromPath;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
const
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const url_1 = require("url");
|
|
4
4
|
/**
|
|
5
5
|
* Removes the directory in the root url from the relative path
|
|
6
6
|
*
|
|
@@ -15,7 +15,7 @@ const stripSubdirectoryFromPath = function stripSubdirectoryFromPath(path = '',
|
|
|
15
15
|
}
|
|
16
16
|
let parsedRoot;
|
|
17
17
|
try {
|
|
18
|
-
parsedRoot = new URL(rootUrl);
|
|
18
|
+
parsedRoot = new url_1.URL(rootUrl);
|
|
19
19
|
}
|
|
20
20
|
catch (e) {
|
|
21
21
|
return path;
|
|
@@ -29,4 +29,4 @@ const stripSubdirectoryFromPath = function stripSubdirectoryFromPath(path = '',
|
|
|
29
29
|
}
|
|
30
30
|
return path;
|
|
31
31
|
};
|
|
32
|
-
|
|
32
|
+
exports.default = stripSubdirectoryFromPath;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { AbsoluteToTransformReadyOptionsInput } from './absolute-to-transform-ready';
|
|
2
|
+
import { type RelativeToAbsoluteOptionsInput } from './relative-to-absolute';
|
|
3
|
+
export type ToTransformReadyOptions = RelativeToAbsoluteOptionsInput & AbsoluteToTransformReadyOptionsInput;
|
|
4
|
+
declare function toTransformReady(url: string, siteUrl: string, itemPath: string | null | ToTransformReadyOptions, options?: ToTransformReadyOptions): string;
|
|
5
|
+
export default toTransformReady;
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const relative_to_absolute_1 = __importDefault(require("./relative-to-absolute"));
|
|
7
|
+
const absolute_to_transform_ready_1 = __importDefault(require("./absolute-to-transform-ready"));
|
|
5
8
|
function toTransformReady(url, siteUrl, itemPath, options) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
let finalItemPath = null;
|
|
10
|
+
let finalOptions = options || {};
|
|
11
|
+
if (typeof itemPath === 'object' && itemPath !== null && !options) {
|
|
12
|
+
finalOptions = itemPath;
|
|
13
|
+
finalItemPath = null;
|
|
9
14
|
}
|
|
10
|
-
|
|
11
|
-
|
|
15
|
+
else if (typeof itemPath === 'string') {
|
|
16
|
+
finalItemPath = itemPath;
|
|
17
|
+
}
|
|
18
|
+
const absoluteUrl = (0, relative_to_absolute_1.default)(url, siteUrl, finalItemPath, finalOptions);
|
|
19
|
+
return (0, absolute_to_transform_ready_1.default)(absoluteUrl, siteUrl, finalOptions);
|
|
12
20
|
}
|
|
13
|
-
|
|
21
|
+
exports.default = toTransformReady;
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import type { TransformReadyReplacementOptions, BaseUrlOptions } from './types';
|
|
2
|
+
export interface TransformReadyToAbsoluteOptions extends TransformReadyReplacementOptions, BaseUrlOptions {
|
|
3
|
+
staticImageUrlPrefix: string;
|
|
4
|
+
staticFilesUrlPrefix: string;
|
|
5
|
+
staticMediaUrlPrefix: string;
|
|
6
|
+
}
|
|
7
|
+
export type TransformReadyToAbsoluteOptionsInput = Partial<TransformReadyToAbsoluteOptions>;
|
|
8
|
+
declare const transformReadyToAbsolute: (str: string | undefined, root: string, _options?: TransformReadyToAbsoluteOptionsInput) => string;
|
|
9
|
+
export default transformReadyToAbsolute;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
function escapeRegExp(string) {
|
|
4
4
|
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
5
5
|
}
|
|
@@ -32,4 +32,4 @@ const transformReadyToAbsolute = function (str = '', root, _options = {}) {
|
|
|
32
32
|
return root.replace(/\/$/, '');
|
|
33
33
|
});
|
|
34
34
|
};
|
|
35
|
-
|
|
35
|
+
exports.default = transformReadyToAbsolute;
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import type { TransformReadyReplacementOptionsInput } from './types';
|
|
2
|
+
declare const transformReadyToRelative: (str: string | undefined, root: string, _options?: TransformReadyReplacementOptionsInput) => string;
|
|
3
|
+
export default transformReadyToRelative;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const url_1 = require("url");
|
|
3
4
|
function escapeRegExp(string) {
|
|
4
5
|
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
5
6
|
}
|
|
@@ -11,10 +12,10 @@ const transformReadyToRelative = function (str = '', root, _options = {}) {
|
|
|
11
12
|
if (!str || str.indexOf(options.replacementStr) === -1) {
|
|
12
13
|
return str;
|
|
13
14
|
}
|
|
14
|
-
const rootURL = new URL(root);
|
|
15
|
+
const rootURL = new url_1.URL(root);
|
|
15
16
|
// subdir with no trailing slash because we'll always have a trailing slash after the magic string
|
|
16
17
|
const subdir = rootURL.pathname.replace(/\/$/, '');
|
|
17
18
|
const replacementRegex = new RegExp(escapeRegExp(options.replacementStr), 'g');
|
|
18
19
|
return str.replace(replacementRegex, subdir);
|
|
19
20
|
};
|
|
20
|
-
|
|
21
|
+
exports.default = transformReadyToRelative;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
export type UnknownRecord = Record<string, unknown>;
|
|
2
|
+
export interface AssetAwareOptions extends UnknownRecord {
|
|
3
|
+
assetsOnly: boolean;
|
|
4
|
+
staticImageUrlPrefix?: string;
|
|
5
|
+
}
|
|
6
|
+
export type AssetAwareOptionsInput = Partial<AssetAwareOptions>;
|
|
7
|
+
export interface SecureOptions extends AssetAwareOptions {
|
|
8
|
+
secure?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export type SecureOptionsInput = Partial<SecureOptions>;
|
|
11
|
+
export interface TransformReadyReplacementOptions extends UnknownRecord {
|
|
12
|
+
replacementStr: string;
|
|
13
|
+
withoutSubdirectory?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export type TransformReadyReplacementOptionsInput = Partial<TransformReadyReplacementOptions>;
|
|
16
|
+
export interface BaseUrlOptions extends UnknownRecord {
|
|
17
|
+
imageBaseUrl?: string | null;
|
|
18
|
+
filesBaseUrl?: string | null;
|
|
19
|
+
mediaBaseUrl?: string | null;
|
|
20
|
+
}
|
|
21
|
+
export type BaseUrlOptionsInput = Partial<BaseUrlOptions>;
|
|
22
|
+
export interface EarlyExitOptions extends UnknownRecord {
|
|
23
|
+
earlyExitMatchStr?: string;
|
|
24
|
+
}
|
|
25
|
+
export type EarlyExitOptionsInput = Partial<EarlyExitOptions>;
|
|
26
|
+
export interface AbsoluteToTransformReadyOptions extends TransformReadyReplacementOptions, BaseUrlOptions, AssetAwareOptions {
|
|
27
|
+
staticFilesUrlPrefix?: string;
|
|
28
|
+
staticMediaUrlPrefix?: string;
|
|
29
|
+
}
|
|
30
|
+
export type AbsoluteToTransformReadyOptionsInput = Partial<AbsoluteToTransformReadyOptions>;
|
|
31
|
+
export type UrlTransformFunction = (url: string, siteUrl: string, itemPath: string | null, options: UnknownRecord) => string;
|
|
32
|
+
export type TransformType = 'relativeToAbsolute' | 'absoluteToRelative' | 'toTransformReady';
|
|
33
|
+
export interface HtmlTransformOptions extends SecureOptions {
|
|
34
|
+
earlyExitMatchStr?: string;
|
|
35
|
+
}
|
|
36
|
+
export type HtmlTransformOptionsInput = SecureOptionsInput & {
|
|
37
|
+
earlyExitMatchStr?: string;
|
|
38
|
+
};
|
|
39
|
+
export interface MarkdownTransformOptions extends AssetAwareOptions {
|
|
40
|
+
ignoreProtocol: boolean;
|
|
41
|
+
earlyExitMatchStr?: string;
|
|
42
|
+
}
|
|
43
|
+
export type MarkdownTransformOptionsInput = AssetAwareOptionsInput & {
|
|
44
|
+
ignoreProtocol?: boolean;
|
|
45
|
+
earlyExitMatchStr?: string;
|
|
46
|
+
};
|
|
47
|
+
export interface MarkdownTransformFunctions {
|
|
48
|
+
html: UrlTransformFunction;
|
|
49
|
+
url: UrlTransformFunction;
|
|
50
|
+
}
|
|
51
|
+
export type CardTransformer = (payload: unknown, options: UnknownRecord) => unknown;
|
|
52
|
+
export interface MobiledocCardTransformer {
|
|
53
|
+
name: string;
|
|
54
|
+
relativeToAbsolute?: CardTransformer;
|
|
55
|
+
absoluteToRelative?: CardTransformer;
|
|
56
|
+
toTransformReady?: CardTransformer;
|
|
57
|
+
}
|
|
58
|
+
export interface MobiledocTransformOptions extends SecureOptions {
|
|
59
|
+
cardTransformers: MobiledocCardTransformer[];
|
|
60
|
+
siteUrl: string;
|
|
61
|
+
itemPath: string | null;
|
|
62
|
+
transformType: TransformType;
|
|
63
|
+
}
|
|
64
|
+
export type MobiledocTransformOptionsInput = Partial<Omit<MobiledocTransformOptions, 'cardTransformers' | 'siteUrl' | 'itemPath' | 'transformType'>> & {
|
|
65
|
+
cardTransformers?: MobiledocCardTransformer[];
|
|
66
|
+
siteUrl?: string;
|
|
67
|
+
itemPath?: string | null;
|
|
68
|
+
transformType?: TransformType;
|
|
69
|
+
};
|
|
70
|
+
export type LexicalTransformFunction = (value: string) => string;
|
|
71
|
+
export interface LexicalUrlTransformMap {
|
|
72
|
+
[key: string]: string | LexicalUrlTransformMap;
|
|
73
|
+
}
|
|
74
|
+
export interface LexicalNodeConfig {
|
|
75
|
+
getType(): string;
|
|
76
|
+
urlTransformMap?: LexicalUrlTransformMap;
|
|
77
|
+
}
|
|
78
|
+
export type LexicalTransformRegistry = Partial<Record<TransformType, Record<string, LexicalTransformFunction>>>;
|
|
79
|
+
export interface LexicalTransformOptions extends SecureOptions {
|
|
80
|
+
nodes: LexicalNodeConfig[];
|
|
81
|
+
transformMap: LexicalTransformRegistry;
|
|
82
|
+
transformType: TransformType;
|
|
83
|
+
siteUrl: string;
|
|
84
|
+
itemPath: string | null;
|
|
85
|
+
}
|
|
86
|
+
export type LexicalTransformOptionsInput = Partial<Omit<LexicalTransformOptions, 'nodes' | 'transformMap' | 'siteUrl' | 'itemPath' | 'transformType'>> & {
|
|
87
|
+
nodes?: LexicalNodeConfig[];
|
|
88
|
+
transformMap?: LexicalTransformRegistry;
|
|
89
|
+
siteUrl?: string;
|
|
90
|
+
itemPath?: string | null;
|
|
91
|
+
transformType?: TransformType;
|
|
92
|
+
};
|
package/lib/utils/url-join.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
interface UrlJoinOptions {
|
|
2
|
+
rootUrl: string;
|
|
3
|
+
}
|
|
2
4
|
/** urlJoin
|
|
3
5
|
* Returns a URL/path for internal use in Ghost.
|
|
4
6
|
* @param {string[]} parts takes parts and concats those to a valid path/URL.
|
|
@@ -6,4 +8,5 @@ declare const deduplicateSubdirectory: any;
|
|
|
6
8
|
* @param {string} options.rootUrl used for deduplicating any subdirectories
|
|
7
9
|
* @return {string} URL concatinated URL/path of arguments.
|
|
8
10
|
*/
|
|
9
|
-
declare function urlJoin(parts:
|
|
11
|
+
declare function urlJoin(parts: string[], options?: UrlJoinOptions): string;
|
|
12
|
+
export default urlJoin;
|
package/lib/utils/url-join.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const deduplicate_subdirectory_1 = __importDefault(require("./deduplicate-subdirectory"));
|
|
4
7
|
/** urlJoin
|
|
5
8
|
* Returns a URL/path for internal use in Ghost.
|
|
6
9
|
* @param {string[]} parts takes parts and concats those to a valid path/URL.
|
|
@@ -8,7 +11,7 @@ const deduplicateSubdirectory = require('./deduplicate-subdirectory');
|
|
|
8
11
|
* @param {string} options.rootUrl used for deduplicating any subdirectories
|
|
9
12
|
* @return {string} URL concatinated URL/path of arguments.
|
|
10
13
|
*/
|
|
11
|
-
function urlJoin(parts, options) {
|
|
14
|
+
function urlJoin(parts, options = { rootUrl: '' }) {
|
|
12
15
|
let prefixDoubleSlash = false;
|
|
13
16
|
// Remove empty item at the beginning
|
|
14
17
|
if (parts[0] === '') {
|
|
@@ -26,6 +29,9 @@ function urlJoin(parts, options) {
|
|
|
26
29
|
if (prefixDoubleSlash) {
|
|
27
30
|
url = url.replace(/^\//, '//');
|
|
28
31
|
}
|
|
29
|
-
|
|
32
|
+
if (!options.rootUrl) {
|
|
33
|
+
return url;
|
|
34
|
+
}
|
|
35
|
+
return (0, deduplicate_subdirectory_1.default)(url, options.rootUrl);
|
|
30
36
|
}
|
|
31
|
-
|
|
37
|
+
exports.default = urlJoin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/url-utils",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/TryGhost/SDK.git",
|
|
@@ -8,20 +8,19 @@
|
|
|
8
8
|
},
|
|
9
9
|
"author": "Ghost Foundation",
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"main": "index.js",
|
|
12
|
-
"types": "lib/
|
|
11
|
+
"main": "lib/index.js",
|
|
12
|
+
"types": "lib/index.d.ts",
|
|
13
13
|
"scripts": {
|
|
14
14
|
"dev": "echo \"Implement me!\"",
|
|
15
15
|
"pretest": "yarn build",
|
|
16
16
|
"test": "NODE_ENV=testing c8 --src lib --all --reporter text --reporter cobertura --reporter html mocha './test/**/*.test.js'",
|
|
17
17
|
"build": "tsc -p tsconfig.json",
|
|
18
|
-
"lint": "eslint src test
|
|
18
|
+
"lint": "eslint src test --ext .js,.ts --cache",
|
|
19
19
|
"prepare": "NODE_ENV=production yarn build",
|
|
20
20
|
"posttest": "yarn lint"
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
|
-
"lib/"
|
|
24
|
-
"index.js"
|
|
23
|
+
"lib/"
|
|
25
24
|
],
|
|
26
25
|
"publishConfig": {
|
|
27
26
|
"access": "public"
|
|
@@ -43,9 +42,9 @@
|
|
|
43
42
|
"lodash": "^4.17.21",
|
|
44
43
|
"moment": "^2.27.0",
|
|
45
44
|
"moment-timezone": "^0.5.31",
|
|
46
|
-
"remark": "
|
|
47
|
-
"remark-footnotes": "
|
|
45
|
+
"remark": "11.0.2",
|
|
46
|
+
"remark-footnotes": "1.0.0",
|
|
48
47
|
"unist-util-visit": "^2.0.0"
|
|
49
48
|
},
|
|
50
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "a97d783ddb64ae80592ec03468b221a4ec37948a"
|
|
51
50
|
}
|
package/index.js
DELETED