@tryghost/mg-linkfixer 0.4.5 → 0.4.6
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/LinkFixer.js +10 -0
- package/package.json +6 -6
package/lib/LinkFixer.js
CHANGED
|
@@ -44,14 +44,24 @@ class LinkFixer {
|
|
|
44
44
|
|
|
45
45
|
// @TODO: support for custom taxonomies
|
|
46
46
|
ctx.result.posts.forEach(({url, data}) => {
|
|
47
|
+
const RegexSlugYYYYMMDD = new RegExp(`^${ctx.options.url}/[a-zA-Z0-9-]+/([0-9]{4}/[0-9]{2}/[0-9]{2})/([a-zA-Z0-9-_]*)(/)?`);
|
|
48
|
+
const isSlugYYYYMMDDDatedPermalink = url.match(RegexSlugYYYYMMDD);
|
|
49
|
+
|
|
47
50
|
const RegexYYYYMMDD = new RegExp(`^${ctx.options.url}/([0-9]{4}/[0-9]{2}/[0-9]{2})/([a-zA-Z0-9-_]*)(/)?`);
|
|
48
51
|
const isYYYYMMDDDatedPermalink = url.match(RegexYYYYMMDD);
|
|
49
52
|
|
|
53
|
+
const RegexSlugYYYYMM = new RegExp(`^${ctx.options.url}/[a-zA-Z0-9-]+/([0-9]{4}/[0-9]{2})/([a-zA-Z0-9-_]*)(/)?`);
|
|
54
|
+
const isSlugYYYYMMDatedPermalink = url.match(RegexSlugYYYYMM);
|
|
55
|
+
|
|
50
56
|
const RegexYYYYMM = new RegExp(`^${ctx.options.url}/([0-9]{4}/[0-9]{2})/([a-zA-Z0-9-_]*)(/)?`);
|
|
51
57
|
const isYYYYMMDatedPermalink = url.match(RegexYYYYMM);
|
|
52
58
|
|
|
53
59
|
if (ctx.options.datedPermalinks === '/yyyy/mm/dd/' && isYYYYMMDDDatedPermalink) {
|
|
54
60
|
this.linkMap[url] = `/${url.replace(RegexYYYYMMDD, '$1/$2')}/`;
|
|
61
|
+
} else if (ctx.options.datedPermalinks === '/*/yyyy/mm/dd/' && isSlugYYYYMMDDDatedPermalink) {
|
|
62
|
+
this.linkMap[url] = `/${url.replace(RegexSlugYYYYMMDD, '$1/$2')}/`;
|
|
63
|
+
} else if (ctx.options.datedPermalinks === '/*/yyyy/mm/' && isSlugYYYYMMDatedPermalink) {
|
|
64
|
+
this.linkMap[url] = `/${url.replace(RegexSlugYYYYMM, '$1/$2')}/`;
|
|
55
65
|
} else if (ctx.options.datedPermalinks === '/yyyy/mm/' && isYYYYMMDatedPermalink) {
|
|
56
66
|
this.linkMap[url] = `/${url.replace(RegexYYYYMM, '$1/$2')}/`;
|
|
57
67
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/mg-linkfixer",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"repository": "https://github.com/TryGhost/migrate/tree/main/packages/mg-linkfixer",
|
|
5
5
|
"author": "Ghost Foundation",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,15 +20,15 @@
|
|
|
20
20
|
"access": "public"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@tryghost/listr-smart-renderer": "^0.4.
|
|
24
|
-
"eslint": "8.
|
|
25
|
-
"jest": "29.
|
|
26
|
-
"jest-extended": "3.
|
|
23
|
+
"@tryghost/listr-smart-renderer": "^0.4.5",
|
|
24
|
+
"eslint": "8.29.0",
|
|
25
|
+
"jest": "29.3.1",
|
|
26
|
+
"jest-extended": "3.2.0",
|
|
27
27
|
"listr": "0.14.3"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"cheerio": "^1.0.0-rc.3",
|
|
31
31
|
"lodash": "4.17.21"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "367c689a814c6ad2bc948a94ca995e1ec8187c76"
|
|
34
34
|
}
|