@tsdoctor/seo 0.4.0 → 0.4.2
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/Canonical.js +14 -2
- package/package.json +2 -2
- package/tsdoc-metadata.json +1 -1
package/Canonical.js
CHANGED
|
@@ -76,9 +76,9 @@ function resolveUrl(siteUrl, url) {
|
|
|
76
76
|
* @public
|
|
77
77
|
*/
|
|
78
78
|
function deriveSiteUrl(siteOrigin, base) {
|
|
79
|
-
const origin = (siteOrigin ?? "").trim()
|
|
79
|
+
const origin = trimSlashesEnd((siteOrigin ?? "").trim());
|
|
80
80
|
const path = (base ?? "/").trim();
|
|
81
|
-
return `${origin}${path === "" || path === "/" ? "" : `/${
|
|
81
|
+
return `${origin}${path === "" || path === "/" ? "" : `/${trimSlashesEnd(trimSlashesStart(path))}`}`;
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
84
84
|
* The canonical URL for a page.
|
|
@@ -94,6 +94,18 @@ function deriveSiteUrl(siteOrigin, base) {
|
|
|
94
94
|
function canonicalUrl(siteUrl, pageRoute) {
|
|
95
95
|
return `${siteUrl.endsWith("/") ? siteUrl.slice(0, -1) : siteUrl}${pageRoute}`;
|
|
96
96
|
}
|
|
97
|
+
/** Strip leading `/` characters with a linear scan rather than a backtracking regex. */
|
|
98
|
+
function trimSlashesStart(text) {
|
|
99
|
+
let start = 0;
|
|
100
|
+
while (start < text.length && text[start] === "/") start++;
|
|
101
|
+
return text.slice(start);
|
|
102
|
+
}
|
|
103
|
+
/** Strip trailing `/` characters with a linear scan rather than a backtracking regex. */
|
|
104
|
+
function trimSlashesEnd(text) {
|
|
105
|
+
let end = text.length;
|
|
106
|
+
while (end > 0 && text[end - 1] === "/") end--;
|
|
107
|
+
return text.slice(0, end);
|
|
108
|
+
}
|
|
97
109
|
|
|
98
110
|
//#endregion
|
|
99
111
|
export { canonicalUrl, deriveSiteUrl, imageMimeType, resolveUrl };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsdoctor/seo",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Framework-neutral head metadata for static TypeScript API documentation: schema.org JSON-LD, Open Graph and Twitter card vocabulary, canonical URLs, and package attribution derived from an api.json model plus its manifest.",
|
|
6
6
|
"keywords": [
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@effected/spdx": "^0.9.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@effected/package-json": "^0.
|
|
43
|
+
"@effected/package-json": "^0.18.0",
|
|
44
44
|
"@effected/schema-org": "^0.5.0",
|
|
45
45
|
"effect": "4.0.0-rc.117"
|
|
46
46
|
},
|