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.1.15 to 0.1.17

2

dist/index.d.ts

@@ -13,4 +13,4 @@ import type { AstroIntegration } from 'astro';

policy?: PolicyItem[];
};
} | undefined;
declare const createPlugin: (pluginOptions?: RobotsTxtOptions) => AstroIntegration;
export default createPlugin;
// src/index.ts
import fs from "fs";
// src/data/package-name.ts
var packageName = "astro-robots-txt";
// src/utils/is-object-empty.ts
// ../utils/src/is-object-empty.ts
var isObjectEmpty = (o) => {

@@ -18,26 +15,48 @@ if (!o) {

// src/with-options.ts
var defaultOptions = {
host: "",
sitemap: true,
policy: [
{
allow: "/",
userAgent: "*"
}
]
// ../utils/src/is-valid-hostname.ts
var isValidHostname = (x) => {
if (typeof x !== "string") {
return false;
}
let value = x.toString();
const validHostnameChars = /^[a-zA-Z0-9-.]{1,253}\.?$/g;
if (!validHostnameChars.test(value)) {
return false;
}
if (value.endsWith(".")) {
value = value.slice(0, value.length - 1);
}
if (value.length > 253) {
return false;
}
return value.split(".").every((label) => /^([a-zA-Z0-9-]+)$/g.test(label) && label.length < 64 && !label.startsWith("-") && !label.endsWith("-"));
};
var withOptions = (pluginOptions) => {
if (isObjectEmpty(pluginOptions)) {
return defaultOptions;
// ../utils/src/is-valid-http-url.ts
var isValidHttpUrl = (s) => {
if (typeof s !== "string" || !s) {
return false;
}
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;
try {
const { protocol } = new URL(s);
return protocol === "http:" || protocol === "https:";
} catch {
return false;
}
};
// src/utils/logger.ts
// ../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
var Logger = class {

@@ -75,45 +94,25 @@ constructor(packageName2) {

// src/utils/is-valid-hostname.ts
var isValidHostname = (x) => {
if (typeof x !== "string") {
return false;
}
let value = x.toString();
const validHostnameChars = /^[a-zA-Z0-9-.]{1,253}\.?$/g;
if (!validHostnameChars.test(value)) {
return false;
}
if (value.endsWith(".")) {
value = value.slice(0, value.length - 1);
}
if (value.length > 253) {
return false;
}
return value.split(".").every((label) => /^([a-zA-Z0-9-]+)$/g.test(label) && label.length < 64 && !label.startsWith("-") && !label.endsWith("-"));
};
// src/data/package-name.ts
var packageName = "astro-robots-txt";
// src/utils/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;
}
// src/with-options.ts
var defaultOptions = {
sitemap: true,
policy: [
{
allow: "/",
userAgent: "*"
}
]
};
// src/utils/is-valid-http-url.ts
var isValidHttpUrl = (s) => {
if (typeof s !== "string" || !s) {
return false;
var withOptions = (pluginOptions) => {
if (isObjectEmpty(pluginOptions)) {
return defaultOptions;
}
try {
const { protocol } = new URL(s);
return protocol === "http:" || protocol === "https:";
} catch {
return false;
}
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;
};

@@ -206,4 +205,5 @@

};
var isOptsValid = (site, { host, sitemap, policy }, _logger) => {
var isOptsValid = (site, opts, _logger) => {
logger = _logger;
const { host, sitemap, policy } = opts || {};
if (!site) {

@@ -262,17 +262,17 @@ logger.warn("`site` property is required in `astro.config.mjs`.");

var getSitemapArr = (sitemap, site) => {
if (typeof sitemap === "boolean" && !sitemap) {
return [];
if (typeof sitemap !== "undefined") {
if (!sitemap) {
return void 0;
}
if (Array.isArray(sitemap)) {
return sitemap.length > 0 ? sitemap : void 0;
}
if (typeof sitemap === "string") {
return [sitemap];
}
}
if (!sitemap) {
return [];
}
if (typeof sitemap === "string") {
return [sitemap];
}
if (Array.isArray(sitemap)) {
return sitemap;
}
return [`${addBackslash(site)}sitemap.xml`];
};
var getRobotsTxtContent = (site, { host, sitemap, policy }) => {
var getRobotsTxtContent = (site, { host, sitemap, policy } = {}) => {
var _a;
let result = "";

@@ -282,3 +282,3 @@ policy == null ? void 0 : policy.forEach((item, index) => {

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

@@ -285,0 +285,0 @@ });

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

@@ -19,11 +19,8 @@ "keywords": [

"type": "git",
"url": "https://github.com/alextim/astro-robots-txt.git"
"url": "https://github.com/alextim/astro-lib.git",
"directory": "packages/astro-robots-txt"
},
"homepage": "https://github.com/alextim/astro-robots-txt#readme",
"bugs": "https://github.com/alextim/astro-robots-txt/issues",
"homepage": "https://github.com/alextim/astro-lib/tree/main/packages/astro-robots-txt#readme",
"bugs": "https://github.com/alextim/astro-lib/issues",
"type": "module",
"workspaces": [
"src",
"demo"
],
"exports": {

@@ -39,30 +36,19 @@ ".": "./dist/index.js",

"devDependencies": {
"@types/jest": "^27.5.0",
"@types/node": "^17.0.31",
"@typescript-eslint/eslint-plugin": "^5.23.0",
"@typescript-eslint/parser": "^5.23.0",
"astro": "^1.0.0-beta.27",
"esbuild": "^0.14.38",
"eslint": "^8.15.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^26.1.5",
"eslint-plugin-prettier": "^4.0.0",
"@types/node": "^17.0.35",
"@types/jest": "^27.5.1",
"at-scripts": "0.0.1",
"astro": "^1.0.0-beta.31",
"jest": "28.1.0",
"prettier": "^2.6.2",
"memfs": "^3.4.3",
"ts-jest": "^28.0.2",
"typescript": "^4.6.4"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
},
"scripts": {
"build": "node scripts/build.mjs && pnpm run build:declarations",
"build": "at-scripts create-pkg-name && at-scripts build && tsc -p tsconfig.build.json && node ./scripts/copy.mjs",
"build:declarations": "tsc -p tsconfig.build.json",
"dev": "astro --root demo dev",
"start": "astro --root demo dev",
"build:demo": "astro --root demo build",
"preview": "astro --root demo preview",
"format": "prettier -w .",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --fix --ext .ts",
"typecheck": "tsc --noEmit",
"test": "jest",

@@ -69,0 +55,0 @@ "test:pub": "pnpm publish --dry-run --no-git-checks"

@@ -9,3 +9,3 @@ <a href="https://war.ukraine.ua/support-ukraine/">

![Publish](https://github.com/alextim/astro-robots-txt/actions/workflows/publish.yaml/badge.svg) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
![Release](https://github.com/alextim/astro-lib/actions/workflows/release.yaml/badge.svg) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)

@@ -25,3 +25,3 @@ ---

**astro-robots-txt** could help in both two cases on the _robots.txt_ side. See details in the demo [repo](https://github.com/alextim/astro-robots-txt/tree/main/demo).
**astro-robots-txt** could help in both two cases on the _robots.txt_ side. See details in the demo [repo](https://github.com/alextim/astro-lib/tree/main/examples/robots-txt).

@@ -49,3 +49,3 @@ ---

If you run into any hiccups, [feel free to log an issue on my GitHub](https://github.com/alextim/astro-robots-txt/issues).
If you run into any hiccups, [feel free to log an issue on my GitHub](https://github.com/alextim/astro-lib/issues).

@@ -52,0 +52,0 @@ ### Install dependencies manually

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