google-indexing-script
Advanced tools
Comparing version 0.2.0 to 0.3.0
# google-indexing-script | ||
## 0.3.0 | ||
### Minor Changes | ||
- [#65](https://github.com/goenning/google-indexing-script/pull/65) [`e0c31f8`](https://github.com/goenning/google-indexing-script/commit/e0c31f837acfe2083843436050b40f21f3806838) Thanks [@AntoineKM](https://github.com/AntoineKM)! - Add custom URLs option | ||
### Patch Changes | ||
- [#65](https://github.com/goenning/google-indexing-script/pull/65) [`e0c31f8`](https://github.com/goenning/google-indexing-script/commit/e0c31f837acfe2083843436050b40f21f3806838) Thanks [@AntoineKM](https://github.com/AntoineKM)! - Fix siteUrls convertions | ||
## 0.2.0 | ||
@@ -4,0 +14,0 @@ |
#!/usr/bin/env node | ||
"use strict";var _chunkVV6RSRMQjs = require('./chunk-VV6RSRMQ.js');require('./chunk-MGWPI7WN.js');require('./chunk-XFI25ILY.js');require('./chunk-KVI7NCRE.js');require('./chunk-OTPIHH5D.js');require('./chunk-3VZ7QZNI.js');require('./chunk-IL7T5FML.js');_chunkVV6RSRMQjs.a.call(void 0, ); | ||
"use strict";var _chunk5WSWEUEVjs = require('./chunk-5WSWEUEV.js');require('./chunk-ILP5CU5A.js');require('./chunk-XFI25ILY.js');require('./chunk-KVI7NCRE.js');require('./chunk-OTPIHH5D.js');require('./chunk-3VZ7QZNI.js');require('./chunk-IL7T5FML.js');_chunk5WSWEUEVjs.a.call(void 0, ); | ||
//# sourceMappingURL=bin.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkVV6RSRMQjs = require('./chunk-VV6RSRMQ.js');require('./chunk-MGWPI7WN.js');require('./chunk-XFI25ILY.js');require('./chunk-KVI7NCRE.js');require('./chunk-OTPIHH5D.js');require('./chunk-3VZ7QZNI.js');require('./chunk-IL7T5FML.js');exports. default = _chunkVV6RSRMQjs.a.call(void 0, ); | ||
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk5WSWEUEVjs = require('./chunk-5WSWEUEV.js');require('./chunk-ILP5CU5A.js');require('./chunk-XFI25ILY.js');require('./chunk-KVI7NCRE.js');require('./chunk-OTPIHH5D.js');require('./chunk-3VZ7QZNI.js');require('./chunk-IL7T5FML.js');exports. default = _chunk5WSWEUEVjs.a.call(void 0, ); | ||
//# sourceMappingURL=cli.js.map |
export { getAccessToken } from './shared/auth.js'; | ||
export { checkSiteUrl, convertToFilePath, convertToHTTP, convertToHTTPS, convertToSCDomain, convertToSiteUrl, getEmojiForStatus, getPageIndexingStatus, getPublishMetadata, getSites, requestIndexing } from './shared/gsc.js'; | ||
export { checkCustomUrls, checkSiteUrl, convertToFilePath, convertToHTTP, convertToHTTPS, convertToSCDomain, convertToSiteUrl, getEmojiForStatus, getPageIndexingStatus, getPublishMetadata, getSites, requestIndexing } from './shared/gsc.js'; | ||
export { getSitemapPages } from './shared/sitemap.js'; | ||
@@ -17,2 +17,3 @@ export { Status } from './shared/types.js'; | ||
path?: string; | ||
urls?: string[]; | ||
quota?: { | ||
@@ -22,4 +23,9 @@ rpmRetry?: boolean; | ||
}; | ||
/** | ||
* Indexes the specified domain or site URL. | ||
* @param input - The domain or site URL to index. | ||
* @param options - (Optional) Additional options for indexing. | ||
*/ | ||
declare const index: (input?: string, options?: IndexOptions) => Promise<void>; | ||
export { type IndexOptions, QUOTA, index }; |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkMGWPI7WNjs = require('./chunk-MGWPI7WN.js');var _chunkXFI25ILYjs = require('./chunk-XFI25ILY.js');var _chunkKVI7NCREjs = require('./chunk-KVI7NCRE.js');var _chunkOTPIHH5Djs = require('./chunk-OTPIHH5D.js');var _chunk3VZ7QZNIjs = require('./chunk-3VZ7QZNI.js');require('./chunk-IL7T5FML.js');_chunkMGWPI7WNjs.q.call(void 0, );exports.QUOTA = _chunkMGWPI7WNjs.n; exports.Status = _chunk3VZ7QZNIjs.a; exports.batch = _chunkOTPIHH5Djs.a; exports.checkSiteUrl = _chunkMGWPI7WNjs.g; exports.convertToFilePath = _chunkMGWPI7WNjs.b; exports.convertToHTTP = _chunkMGWPI7WNjs.d; exports.convertToHTTPS = _chunkMGWPI7WNjs.e; exports.convertToSCDomain = _chunkMGWPI7WNjs.c; exports.convertToSiteUrl = _chunkMGWPI7WNjs.a; exports.fetchRetry = _chunkOTPIHH5Djs.b; exports.getAccessToken = _chunkXFI25ILYjs.a; exports.getEmojiForStatus = _chunkMGWPI7WNjs.i; exports.getPageIndexingStatus = _chunkMGWPI7WNjs.h; exports.getPublishMetadata = _chunkMGWPI7WNjs.j; exports.getSitemapPages = _chunkKVI7NCREjs.a; exports.getSites = _chunkMGWPI7WNjs.f; exports.index = _chunkMGWPI7WNjs.o; exports.parseCommandLineArgs = _chunkOTPIHH5Djs.c; exports.requestIndexing = _chunkMGWPI7WNjs.k; | ||
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkILP5CU5Ajs = require('./chunk-ILP5CU5A.js');var _chunkXFI25ILYjs = require('./chunk-XFI25ILY.js');var _chunkKVI7NCREjs = require('./chunk-KVI7NCRE.js');var _chunkOTPIHH5Djs = require('./chunk-OTPIHH5D.js');var _chunk3VZ7QZNIjs = require('./chunk-3VZ7QZNI.js');require('./chunk-IL7T5FML.js');_chunkILP5CU5Ajs.r.call(void 0, );exports.QUOTA = _chunkILP5CU5Ajs.o; exports.Status = _chunk3VZ7QZNIjs.a; exports.batch = _chunkOTPIHH5Djs.a; exports.checkCustomUrls = _chunkILP5CU5Ajs.h; exports.checkSiteUrl = _chunkILP5CU5Ajs.g; exports.convertToFilePath = _chunkILP5CU5Ajs.b; exports.convertToHTTP = _chunkILP5CU5Ajs.d; exports.convertToHTTPS = _chunkILP5CU5Ajs.e; exports.convertToSCDomain = _chunkILP5CU5Ajs.c; exports.convertToSiteUrl = _chunkILP5CU5Ajs.a; exports.fetchRetry = _chunkOTPIHH5Djs.b; exports.getAccessToken = _chunkXFI25ILYjs.a; exports.getEmojiForStatus = _chunkILP5CU5Ajs.j; exports.getPageIndexingStatus = _chunkILP5CU5Ajs.i; exports.getPublishMetadata = _chunkILP5CU5Ajs.k; exports.getSitemapPages = _chunkKVI7NCREjs.a; exports.getSites = _chunkILP5CU5Ajs.f; exports.index = _chunkILP5CU5Ajs.p; exports.parseCommandLineArgs = _chunkOTPIHH5Djs.c; exports.requestIndexing = _chunkILP5CU5Ajs.l; | ||
//# sourceMappingURL=index.js.map |
@@ -0,3 +1,10 @@ | ||
/** | ||
* Retrieves an access token for Google APIs using service account credentials. | ||
* @param client_email - The client email of the service account. | ||
* @param private_key - The private key of the service account. | ||
* @param customPath - (Optional) Custom path to the service account JSON file. | ||
* @returns The access token. | ||
*/ | ||
declare function getAccessToken(client_email?: string, private_key?: string, customPath?: string): Promise<string | null | undefined>; | ||
export { getAccessToken }; |
import { Status } from './types.js'; | ||
/** | ||
* Converts a given input string to a valid Google Search Console site URL format. | ||
* @param input - The input string to be converted. | ||
* @returns The converted site URL (domain.com or https://domain.com/) | ||
*/ | ||
declare function convertToSiteUrl(input: string): string; | ||
/** | ||
* Converts a given file path to a formatted version suitable for use as a file name. | ||
* @param path - The url to be converted as a file name | ||
* @returns The converted file path | ||
*/ | ||
declare function convertToFilePath(path: string): string; | ||
/** | ||
* Converts an HTTP URL to a sc-domain URL format. | ||
* @param httpUrl The HTTP URL to be converted. | ||
* @returns The sc-domain formatted URL. | ||
*/ | ||
declare function convertToSCDomain(httpUrl: string): string; | ||
/** | ||
* Converts a domain to an HTTP URL. | ||
* @param domain The domain to be converted. | ||
* @returns The HTTP URL. | ||
*/ | ||
declare function convertToHTTP(domain: string): string; | ||
/** | ||
* Converts a domain to an HTTPS URL. | ||
* @param domain The domain to be converted. | ||
* @returns The HTTPS URL. | ||
*/ | ||
declare function convertToHTTPS(domain: string): string; | ||
/** | ||
* Retrieves a list of sites associated with the specified service account from the Google Webmasters API. | ||
* @param accessToken - The access token for authentication. | ||
* @returns An array containing the site URLs associated with the service account. | ||
*/ | ||
declare function getSites(accessToken: string): Promise<(string | null | undefined)[]>; | ||
/** | ||
* Checks if the site URL is valid and accessible by the service account. | ||
* @param accessToken - The access token for authentication. | ||
* @param siteUrl - The URL of the site to check. | ||
* @returns The corrected URL if found, otherwise the original site URL. | ||
*/ | ||
declare function checkSiteUrl(accessToken: string, siteUrl: string): Promise<string>; | ||
/** | ||
* Checks if the given URLs are valid. | ||
* @param siteUrl - The URL of the site. | ||
* @param urls - The URLs to check. | ||
* @returns An array containing the corrected URLs if found, otherwise the original URLs | ||
*/ | ||
declare function checkCustomUrls(siteUrl: string, urls: string[]): string[]; | ||
/** | ||
* Retrieves the indexing status of a page. | ||
* @param accessToken - The access token for authentication. | ||
* @param siteUrl - The URL of the site. | ||
* @param inspectionUrl - The URL of the page to inspect. | ||
* @returns A promise resolving to the status of indexing. | ||
*/ | ||
declare function getPageIndexingStatus(accessToken: string, siteUrl: string, inspectionUrl: string): Promise<Status>; | ||
/** | ||
* Retrieves an emoji representation corresponding to the given status. | ||
* @param status - The status for which to retrieve the emoji. | ||
* @returns The emoji representing the status. | ||
*/ | ||
declare function getEmojiForStatus(status: Status): "✅" | "😵" | "👀" | "🔀" | "❓" | "🚦" | "❌"; | ||
/** | ||
* Retrieves metadata for publishing from the given URL. | ||
* @param accessToken - The access token for authentication. | ||
* @param url - The URL for which to retrieve metadata. | ||
* @param options - The options for the request. | ||
* @returns The status of the request. | ||
*/ | ||
declare function getPublishMetadata(accessToken: string, url: string, options?: { | ||
retriesOnRateLimit: number; | ||
}): Promise<number>; | ||
/** | ||
* Requests indexing for the given URL. | ||
* @param accessToken - The access token for authentication. | ||
* @param url - The URL to be indexed. | ||
*/ | ||
declare function requestIndexing(accessToken: string, url: string): Promise<void>; | ||
export { checkSiteUrl, convertToFilePath, convertToHTTP, convertToHTTPS, convertToSCDomain, convertToSiteUrl, getEmojiForStatus, getPageIndexingStatus, getPublishMetadata, getSites, requestIndexing }; | ||
export { checkCustomUrls, checkSiteUrl, convertToFilePath, convertToHTTP, convertToHTTPS, convertToSCDomain, convertToSiteUrl, getEmojiForStatus, getPageIndexingStatus, getPublishMetadata, getSites, requestIndexing }; |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkMGWPI7WNjs = require('../chunk-MGWPI7WN.js');require('../chunk-XFI25ILY.js');require('../chunk-KVI7NCRE.js');require('../chunk-OTPIHH5D.js');require('../chunk-3VZ7QZNI.js');require('../chunk-IL7T5FML.js');_chunkMGWPI7WNjs.l.call(void 0, );exports.checkSiteUrl = _chunkMGWPI7WNjs.g; exports.convertToFilePath = _chunkMGWPI7WNjs.b; exports.convertToHTTP = _chunkMGWPI7WNjs.d; exports.convertToHTTPS = _chunkMGWPI7WNjs.e; exports.convertToSCDomain = _chunkMGWPI7WNjs.c; exports.convertToSiteUrl = _chunkMGWPI7WNjs.a; exports.getEmojiForStatus = _chunkMGWPI7WNjs.i; exports.getPageIndexingStatus = _chunkMGWPI7WNjs.h; exports.getPublishMetadata = _chunkMGWPI7WNjs.j; exports.getSites = _chunkMGWPI7WNjs.f; exports.requestIndexing = _chunkMGWPI7WNjs.k; | ||
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkILP5CU5Ajs = require('../chunk-ILP5CU5A.js');require('../chunk-XFI25ILY.js');require('../chunk-KVI7NCRE.js');require('../chunk-OTPIHH5D.js');require('../chunk-3VZ7QZNI.js');require('../chunk-IL7T5FML.js');_chunkILP5CU5Ajs.m.call(void 0, );exports.checkCustomUrls = _chunkILP5CU5Ajs.h; exports.checkSiteUrl = _chunkILP5CU5Ajs.g; exports.convertToFilePath = _chunkILP5CU5Ajs.b; exports.convertToHTTP = _chunkILP5CU5Ajs.d; exports.convertToHTTPS = _chunkILP5CU5Ajs.e; exports.convertToSCDomain = _chunkILP5CU5Ajs.c; exports.convertToSiteUrl = _chunkILP5CU5Ajs.a; exports.getEmojiForStatus = _chunkILP5CU5Ajs.j; exports.getPageIndexingStatus = _chunkILP5CU5Ajs.i; exports.getPublishMetadata = _chunkILP5CU5Ajs.k; exports.getSites = _chunkILP5CU5Ajs.f; exports.requestIndexing = _chunkILP5CU5Ajs.l; | ||
//# sourceMappingURL=gsc.js.map |
export { getAccessToken } from './auth.js'; | ||
export { checkSiteUrl, convertToFilePath, convertToHTTP, convertToHTTPS, convertToSCDomain, convertToSiteUrl, getEmojiForStatus, getPageIndexingStatus, getPublishMetadata, getSites, requestIndexing } from './gsc.js'; | ||
export { checkCustomUrls, checkSiteUrl, convertToFilePath, convertToHTTP, convertToHTTPS, convertToSCDomain, convertToSiteUrl, getEmojiForStatus, getPageIndexingStatus, getPublishMetadata, getSites, requestIndexing } from './gsc.js'; | ||
export { getSitemapPages } from './sitemap.js'; | ||
export { Status } from './types.js'; | ||
export { batch, fetchRetry, parseCommandLineArgs } from './utils.js'; |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkMGWPI7WNjs = require('../chunk-MGWPI7WN.js');var _chunkXFI25ILYjs = require('../chunk-XFI25ILY.js');var _chunkKVI7NCREjs = require('../chunk-KVI7NCRE.js');var _chunkOTPIHH5Djs = require('../chunk-OTPIHH5D.js');var _chunk3VZ7QZNIjs = require('../chunk-3VZ7QZNI.js');require('../chunk-IL7T5FML.js');_chunkMGWPI7WNjs.m.call(void 0, );exports.Status = _chunk3VZ7QZNIjs.a; exports.batch = _chunkOTPIHH5Djs.a; exports.checkSiteUrl = _chunkMGWPI7WNjs.g; exports.convertToFilePath = _chunkMGWPI7WNjs.b; exports.convertToHTTP = _chunkMGWPI7WNjs.d; exports.convertToHTTPS = _chunkMGWPI7WNjs.e; exports.convertToSCDomain = _chunkMGWPI7WNjs.c; exports.convertToSiteUrl = _chunkMGWPI7WNjs.a; exports.fetchRetry = _chunkOTPIHH5Djs.b; exports.getAccessToken = _chunkXFI25ILYjs.a; exports.getEmojiForStatus = _chunkMGWPI7WNjs.i; exports.getPageIndexingStatus = _chunkMGWPI7WNjs.h; exports.getPublishMetadata = _chunkMGWPI7WNjs.j; exports.getSitemapPages = _chunkKVI7NCREjs.a; exports.getSites = _chunkMGWPI7WNjs.f; exports.parseCommandLineArgs = _chunkOTPIHH5Djs.c; exports.requestIndexing = _chunkMGWPI7WNjs.k; | ||
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkILP5CU5Ajs = require('../chunk-ILP5CU5A.js');var _chunkXFI25ILYjs = require('../chunk-XFI25ILY.js');var _chunkKVI7NCREjs = require('../chunk-KVI7NCRE.js');var _chunkOTPIHH5Djs = require('../chunk-OTPIHH5D.js');var _chunk3VZ7QZNIjs = require('../chunk-3VZ7QZNI.js');require('../chunk-IL7T5FML.js');_chunkILP5CU5Ajs.n.call(void 0, );exports.Status = _chunk3VZ7QZNIjs.a; exports.batch = _chunkOTPIHH5Djs.a; exports.checkCustomUrls = _chunkILP5CU5Ajs.h; exports.checkSiteUrl = _chunkILP5CU5Ajs.g; exports.convertToFilePath = _chunkILP5CU5Ajs.b; exports.convertToHTTP = _chunkILP5CU5Ajs.d; exports.convertToHTTPS = _chunkILP5CU5Ajs.e; exports.convertToSCDomain = _chunkILP5CU5Ajs.c; exports.convertToSiteUrl = _chunkILP5CU5Ajs.a; exports.fetchRetry = _chunkOTPIHH5Djs.b; exports.getAccessToken = _chunkXFI25ILYjs.a; exports.getEmojiForStatus = _chunkILP5CU5Ajs.j; exports.getPageIndexingStatus = _chunkILP5CU5Ajs.i; exports.getPublishMetadata = _chunkILP5CU5Ajs.k; exports.getSitemapPages = _chunkKVI7NCREjs.a; exports.getSites = _chunkILP5CU5Ajs.f; exports.parseCommandLineArgs = _chunkOTPIHH5Djs.c; exports.requestIndexing = _chunkILP5CU5Ajs.l; | ||
//# sourceMappingURL=index.js.map |
@@ -0,3 +1,9 @@ | ||
/** | ||
* Retrieves a list of pages from all sitemaps associated with the specified site URL. | ||
* @param accessToken The access token for authentication. | ||
* @param siteUrl The URL of the site for which to retrieve the sitemap pages. | ||
* @returns An array containing the list of sitemaps and an array of unique page URLs extracted from those sitemaps. | ||
*/ | ||
declare function getSitemapPages(accessToken: string, siteUrl: string): Promise<string[][]>; | ||
export { getSitemapPages }; |
@@ -0,1 +1,4 @@ | ||
/** | ||
* Enum representing indexing status of a URL | ||
*/ | ||
declare enum Status { | ||
@@ -2,0 +5,0 @@ SubmittedAndIndexed = "Submitted and indexed", |
@@ -0,3 +1,23 @@ | ||
/** | ||
* Executes tasks on items in batches and invokes a callback upon completion of each batch. | ||
* @param task The task function to be executed on each item. | ||
* @param items The array of items on which the task is to be executed. | ||
* @param batchSize The size of each batch. | ||
* @param onBatchComplete The callback function invoked upon completion of each batch. | ||
*/ | ||
declare function batch(task: (url: string) => void, items: string[], batchSize: number, onBatchComplete: (batchIndex: number, batchCount: number) => void): Promise<void>; | ||
/** | ||
* Fetches a resource from a URL with retry logic. | ||
* @param url The URL of the resource to fetch. | ||
* @param options The options for the fetch request. | ||
* @param retries The number of retry attempts (default is 5). | ||
* @returns A Promise resolving to the fetched response. | ||
* @throws Error when retries are exhausted or server error occurs. | ||
*/ | ||
declare function fetchRetry(url: string, options: RequestInit, retries?: number): Promise<Response>; | ||
/** | ||
* Parses command-line arguments and returns key-value pairs. | ||
* @param argv The array of command-line arguments. | ||
* @returns An object containing parsed key-value pairs. | ||
*/ | ||
declare function parseCommandLineArgs(argv: string[]): { | ||
@@ -4,0 +24,0 @@ [key: string]: string; |
{ | ||
"name": "google-indexing-script", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"main": "./dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "./dist/index.d.ts", |
@@ -134,3 +134,3 @@ # Google Indexing Script | ||
Read the [API documentation](https://paka.dev/npm/google-indexing-script) for more details. | ||
Read the [API documentation](https://jsdocs.io/package/google-indexing-script) for more details. | ||
@@ -137,0 +137,0 @@ </details> |
@@ -10,2 +10,3 @@ import { getAccessToken } from "./shared/auth"; | ||
checkSiteUrl, | ||
checkCustomUrls, | ||
} from "./shared/gsc"; | ||
@@ -30,2 +31,3 @@ import { getSitemapPages } from "./shared/sitemap"; | ||
path?: string; | ||
urls?: string[]; | ||
quota?: { | ||
@@ -58,2 +60,5 @@ rpmRetry?: boolean; // read requests per minute: retry after waiting time | ||
} | ||
if (!options.urls) { | ||
options.urls = args["urls"] ? args["urls"].split(",") : undefined; | ||
} | ||
if (!options.quota) { | ||
@@ -78,12 +83,21 @@ options.quota = { | ||
const [sitemaps, pages] = await getSitemapPages(accessToken, siteUrl); | ||
let pages = options.urls || []; | ||
if (pages.length === 0) { | ||
console.log(`🔎 Fetching sitemaps and pages...`); | ||
const [sitemaps, pagesFromSitemaps] = await getSitemapPages(accessToken, siteUrl); | ||
if (sitemaps.length === 0) { | ||
console.error("❌ No sitemaps found, add them to Google Search Console and try again."); | ||
console.error(""); | ||
process.exit(1); | ||
if (sitemaps.length === 0) { | ||
console.error("❌ No sitemaps found, add them to Google Search Console and try again."); | ||
console.error(""); | ||
process.exit(1); | ||
} | ||
pages = pagesFromSitemaps; | ||
console.log(`👉 Found ${pages.length} URLs in ${sitemaps.length} sitemap`); | ||
} else { | ||
pages = checkCustomUrls(siteUrl, pages); | ||
console.log(`👉 Found ${pages.length} URLs in the provided list`); | ||
} | ||
console.log(`👉 Found ${pages.length} URLs in ${sitemaps.length} sitemap`); | ||
const statusPerUrl: Record<string, { status: Status; lastCheckedAt: string }> = existsSync(cachePath) | ||
@@ -116,3 +130,3 @@ ? JSON.parse(readFileSync(cachePath, "utf8")) | ||
const isOld = new Date(lastCheckedAt) < new Date(Date.now() - CACHE_TIMEOUT); | ||
return shouldIndexIt && isOld;; | ||
return shouldIndexIt && isOld; | ||
}; | ||
@@ -119,0 +133,0 @@ |
@@ -95,7 +95,7 @@ import { webmasters_v3 } from "googleapis"; | ||
formattedUrls.push(siteUrl); | ||
formattedUrls.push(convertToHTTP(siteUrl)); | ||
formattedUrls.push(convertToHTTP(siteUrl.replace("https://", ""))); | ||
formattedUrls.push(convertToSCDomain(siteUrl)); | ||
} else if (siteUrl.startsWith("http://")) { | ||
formattedUrls.push(siteUrl); | ||
formattedUrls.push(convertToHTTPS(siteUrl)); | ||
formattedUrls.push(convertToHTTPS(siteUrl.replace("http://", ""))); | ||
formattedUrls.push(convertToSCDomain(siteUrl)); | ||
@@ -126,2 +126,31 @@ } else if (siteUrl.startsWith("sc-domain:")) { | ||
/** | ||
* Checks if the given URLs are valid. | ||
* @param siteUrl - The URL of the site. | ||
* @param urls - The URLs to check. | ||
* @returns An array containing the corrected URLs if found, otherwise the original URLs | ||
*/ | ||
export function checkCustomUrls(siteUrl: string, urls: string[]) { | ||
const protocol = siteUrl.startsWith("http://") ? "http://" : "https://"; | ||
const domain = siteUrl.replace("https://", "").replace("http://", "").replace("sc-domain:", ""); | ||
const formattedUrls: string[] = urls.map((url) => { | ||
url = url.trim(); | ||
if (url.startsWith("/")) { | ||
// the url is a relative path (e.g. /about) | ||
return `${protocol}${domain}${url}`; | ||
} else if (url.startsWith("http://") || url.startsWith("https://")) { | ||
// the url is already a full url (e.g. https://domain.com/about) | ||
return url; | ||
} else if (url.startsWith(domain)) { | ||
// the url is a full url without the protocol (e.g. domain.com/about) | ||
return `${protocol}${url}`; | ||
} else { | ||
// the url is a relative path without the leading slash (e.g. about) | ||
return `${protocol}${domain}/${url}`; | ||
} | ||
}); | ||
return formattedUrls; | ||
} | ||
/** | ||
* Retrieves the indexing status of a page. | ||
@@ -128,0 +157,0 @@ * @param accessToken - The access token for authentication. |
@@ -10,3 +10,3 @@ { | ||
"moduleResolution": "node", | ||
"removeComments": true, | ||
"removeComments": false, | ||
"noImplicitAny": false, | ||
@@ -13,0 +13,0 @@ "strictNullChecks": true, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 3 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 3 instances in 1 package
136370
963