gscdump 0.26.4 → 0.26.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/dist/index.mjs +1 -1
- package/dist/normalize.d.mts +2 -0
- package/dist/normalize.mjs +16 -0
- package/dist/tenant.d.mts +18 -0
- package/dist/tenant.mjs +18 -0
- package/package.json +12 -2
package/dist/index.mjs
CHANGED
|
@@ -621,7 +621,7 @@ function getPstDateDaysAgo(daysAgo) {
|
|
|
621
621
|
return toIsoDate(pstNow);
|
|
622
622
|
}
|
|
623
623
|
function daysAgo(n) {
|
|
624
|
-
return toIsoDate(new Date(Date.now() - n * MS_PER_DAY));
|
|
624
|
+
return toIsoDate(/* @__PURE__ */ new Date(Date.now() - n * MS_PER_DAY));
|
|
625
625
|
}
|
|
626
626
|
function getLatestGscDate() {
|
|
627
627
|
return getPstDateDaysAgo(3);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const URL_PROTOCOL_RE = /^[a-z][a-z0-9+.-]*:\/\//i;
|
|
2
|
+
function normalizeUrl(input) {
|
|
3
|
+
if (!input) return input;
|
|
4
|
+
if (!URL_PROTOCOL_RE.test(input)) return input.startsWith("/") ? input : `/${input}`;
|
|
5
|
+
const parsed = safeParse(input);
|
|
6
|
+
if (!parsed) return input;
|
|
7
|
+
return `${parsed.pathname}${parsed.search}${parsed.hash}`;
|
|
8
|
+
}
|
|
9
|
+
function safeParse(input) {
|
|
10
|
+
try {
|
|
11
|
+
return new URL(input);
|
|
12
|
+
} catch {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export { normalizeUrl };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
declare function encodeSiteId(siteUrl: string): string;
|
|
2
|
+
/**
|
|
3
|
+
* Best-effort inverse of `encodeSiteId` for the common prefixes. Lossy
|
|
4
|
+
* (`encodeSiteId` collapses non-word chars to `_` and strips trailing
|
|
5
|
+
* underscores), but round-trips domain properties + https origins cleanly —
|
|
6
|
+
* the only two shapes GSC hands out in practice.
|
|
7
|
+
*
|
|
8
|
+
* Returns the input unchanged when neither prefix is recognised, so callers
|
|
9
|
+
* can pass through canonical site URLs without branching.
|
|
10
|
+
*/
|
|
11
|
+
declare function decodeSiteId(encoded: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Normalize a siteUrl to the form Google APIs expect: domain properties get
|
|
14
|
+
* the `sc-domain:` prefix added if missing, URL properties pass through.
|
|
15
|
+
* Idempotent — safe to call on already-prefixed values.
|
|
16
|
+
*/
|
|
17
|
+
declare function normalizeSiteUrl(siteUrl: string): string;
|
|
18
|
+
export { decodeSiteId, encodeSiteId, normalizeSiteUrl };
|
package/dist/tenant.mjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const SC_DOMAIN_RE = /^sc-domain:/;
|
|
2
|
+
const PROTOCOL_RE = /^https?:\/\//;
|
|
3
|
+
const NON_ID_RE = /[^\w.-]/g;
|
|
4
|
+
const TRAILING_UNDERSCORES_RE = /_+$/;
|
|
5
|
+
function encodeSiteId(siteUrl) {
|
|
6
|
+
return siteUrl.replace(SC_DOMAIN_RE, "d_").replace(PROTOCOL_RE, "h_").replace(NON_ID_RE, "_").replace(TRAILING_UNDERSCORES_RE, "");
|
|
7
|
+
}
|
|
8
|
+
function decodeSiteId(encoded) {
|
|
9
|
+
if (encoded.startsWith("d_")) return `sc-domain:${encoded.slice(2)}`;
|
|
10
|
+
if (encoded.startsWith("h_")) return `https://${encoded.slice(2)}/`;
|
|
11
|
+
return encoded;
|
|
12
|
+
}
|
|
13
|
+
function normalizeSiteUrl(siteUrl) {
|
|
14
|
+
if (siteUrl.startsWith("sc-domain:")) return siteUrl;
|
|
15
|
+
if (siteUrl.startsWith("http://") || siteUrl.startsWith("https://")) return siteUrl;
|
|
16
|
+
return `sc-domain:${siteUrl}`;
|
|
17
|
+
}
|
|
18
|
+
export { decodeSiteId, encodeSiteId, normalizeSiteUrl };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gscdump",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.26.
|
|
4
|
+
"version": "0.26.6",
|
|
5
5
|
"description": "Google Search Console API wrapper with typed query builder, streaming pagination, and SEO analysis functions",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Harlan Wilton",
|
|
@@ -56,6 +56,16 @@
|
|
|
56
56
|
"types": "./dist/contracts.d.mts",
|
|
57
57
|
"import": "./dist/contracts.mjs",
|
|
58
58
|
"default": "./dist/contracts.mjs"
|
|
59
|
+
},
|
|
60
|
+
"./normalize": {
|
|
61
|
+
"types": "./dist/normalize.d.mts",
|
|
62
|
+
"import": "./dist/normalize.mjs",
|
|
63
|
+
"default": "./dist/normalize.mjs"
|
|
64
|
+
},
|
|
65
|
+
"./tenant": {
|
|
66
|
+
"types": "./dist/tenant.d.mts",
|
|
67
|
+
"import": "./dist/tenant.mjs",
|
|
68
|
+
"default": "./dist/tenant.mjs"
|
|
59
69
|
}
|
|
60
70
|
},
|
|
61
71
|
"main": "./dist/index.mjs",
|
|
@@ -83,7 +93,7 @@
|
|
|
83
93
|
"defu": "^6.1.7",
|
|
84
94
|
"ofetch": "^1.5.1",
|
|
85
95
|
"ufo": "^1.6.4",
|
|
86
|
-
"@gscdump/contracts": "0.26.
|
|
96
|
+
"@gscdump/contracts": "0.26.6"
|
|
87
97
|
},
|
|
88
98
|
"devDependencies": {
|
|
89
99
|
"@googleapis/indexing": "^6.0.1",
|