New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

astro-robots-txt

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

astro-robots-txt - npm Package Compare versions

Comparing version 0.3.2 to 0.3.3

110

dist/index.js

@@ -1,32 +0,4 @@

var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
// src/index.ts
import { ZodError } from "zod";
// ../utils/src/is-object-empty.ts
var isObjectEmpty = (o) => {
if (!o) {
return true;
}
if (Array.isArray(o)) {
return o.length === 0;
}
return Object.keys(o).length === 0 && Object.getPrototypeOf(o) === Object.prototype;
};
// ../utils/src/is-valid-hostname.ts

@@ -64,15 +36,2 @@ var isValidHostname = (x) => {

// ../utils/src/is-valid-url.ts
var isValidUrl = (s) => {
if (typeof s !== "string" || !s) {
return false;
}
try {
const dummy = new URL(s);
return true;
} catch {
return false;
}
};
// ../utils/src/logger.ts

@@ -154,4 +113,10 @@ var Logger = class {

// src/with-options.ts
var defaultOptions = {
// src/validate-options.ts
import { z as z2 } from "zod";
// src/schema.ts
import { z } from "zod";
// src/config-defaults.ts
var ROBOTS_TXT_CONFIG_DEFAULTS = {
sitemap: true,

@@ -165,23 +130,6 @@ policy: [

};
var withOptions = (pluginOptions) => {
if (isObjectEmpty(pluginOptions)) {
return defaultOptions;
}
const options = {
host: pluginOptions == null ? void 0 : pluginOptions.host,
sitemap: typeof (pluginOptions == null ? void 0 : pluginOptions.sitemap) === "undefined" ? true : pluginOptions.sitemap,
policy: (pluginOptions == null ? void 0 : pluginOptions.policy) || defaultOptions.policy
};
return options;
};
// src/validate-opts.ts
import { z as z2 } from "zod";
// src/schema.ts
import { z } from "zod";
var validateSitemapItem = () => z.string().min(1).refine((val) => !val || isValidUrl(val), {
message: "Not valid url"
}).refine((val) => !val || isValidHttpUrl(val), {
message: "Only `http` or `https` protocol allowed"
var validateSitemapItem = () => z.string().min(1).refine((val) => !val || isValidHttpUrl(val), {
message: "Only valid URLs with `http` or `https` protocol allowed"
});

@@ -193,3 +141,3 @@ var validateCleanParam = () => z.string().max(500);

}),
sitemap: validateSitemapItem().or(validateSitemapItem().array()).or(z.boolean()).optional().default(true),
sitemap: validateSitemapItem().or(validateSitemapItem().array()).or(z.boolean()).optional().default(ROBOTS_TXT_CONFIG_DEFAULTS.sitemap),
policy: z.object({

@@ -200,14 +148,14 @@ userAgent: z.string().min(1),

cleanParam: validateCleanParam().or(validateCleanParam().array()).optional(),
crawlDelay: z.number().nonnegative().refine((val) => typeof val === "undefined" || Number.isFinite(val), { message: "Must be finite number" }).optional()
}).array().nonempty().optional()
});
crawlDelay: z.number().nonnegative().optional().refine((val) => typeof val === "undefined" || Number.isFinite(val), { message: "Must be finite number" })
}).array().nonempty().optional().default(ROBOTS_TXT_CONFIG_DEFAULTS.policy)
}).default(ROBOTS_TXT_CONFIG_DEFAULTS);
// src/validate-opts.ts
var validateOpts = (site, opts) => {
const schema = RobotsTxtOptionsSchema.extend({
site: z2.string().min(1, {
message: "`site` property is required in `astro.config.*`."
})
// src/validate-options.ts
var validateOptions = (site, opts) => {
const siteSchema = z2.string().min(1, {
message: "`site` property is required in `astro.config.*`."
});
schema.parse(__spreadValues({ site: site || "" }, opts || {}));
siteSchema.parse(site);
const result = RobotsTxtOptionsSchema.parse(opts);
return result;
};

@@ -217,3 +165,3 @@

var capitaliseFirstLetter = (s) => s.charAt(0).toUpperCase() + s.slice(1);
var addBackslash = (s) => s.endsWith("/") ? s : `${s}/`;
var addBackSlash = (s) => s.endsWith("/") ? s : `${s}/`;
var addLine = (name, rule) => {

@@ -251,3 +199,3 @@ if (rule && Array.isArray(rule) && rule.length > 0) {

};
var getSitemapArr = (sitemap, site) => {
var getSitemapArr = (sitemap, filalSiteHref) => {
if (typeof sitemap !== "undefined") {

@@ -264,5 +212,5 @@ if (!sitemap) {

}
return [`${addBackslash(site)}sitemap.xml`];
return [`${addBackSlash(filalSiteHref)}sitemap.xml`];
};
var getRobotsTxtContent = (site, { host, sitemap, policy } = {}) => {
var getRobotsTxtContent = (finalSiteHref, { host, sitemap, policy } = {}) => {
var _a;

@@ -273,3 +221,3 @@ let result = "";

});
(_a = getSitemapArr(sitemap, site)) == null ? void 0 : _a.forEach((item) => {
(_a = getSitemapArr(sitemap, finalSiteHref)) == null ? void 0 : _a.forEach((item) => {
result += addLine("Sitemap", item);

@@ -285,5 +233,5 @@ });

var onBuildDone = (pluginOptions, config, dir) => {
const opts = withOptions(pluginOptions);
validateOpts(config.site, opts);
const robotsTxtContent = getRobotsTxtContent(config.site, opts);
const opts = validateOptions(config.site, pluginOptions);
const finalSiteHref = new URL(config.base, config.site).href;
const robotsTxtContent = getRobotsTxtContent(finalSiteHref, opts);
const url = new URL("robots.txt", dir);

@@ -290,0 +238,0 @@ fs2.writeFileSync(url, robotsTxtContent);

{
"name": "astro-robots-txt",
"version": "0.3.2",
"version": "0.3.3",
"description": "Generate a robots.txt for Astro",

@@ -39,9 +39,9 @@ "keywords": [

"devDependencies": {
"@types/node": "^17.0.41",
"astro": "^1.0.0-beta.42",
"@types/node": "^17.0.43",
"astro": "^1.0.0-beta.46",
"at-scripts": "0.0.4",
"c8": "^7.11.3",
"typescript": "^4.7.3",
"vite": "^2.9.10",
"vitest": "^0.14.1"
"vite": "^2.9.12",
"vitest": "^0.15.1"
},

@@ -48,0 +48,0 @@ "publishConfig": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc