full site update
This commit is contained in:
4
node_modules/@astrojs/internal-helpers/dist/fs.js
generated
vendored
4
node_modules/@astrojs/internal-helpers/dist/fs.js
generated
vendored
@@ -26,8 +26,8 @@ async function getFilesFromFolder(dir) {
|
||||
return files;
|
||||
}
|
||||
async function copyFilesToFolder(files, outDir, exclude = []) {
|
||||
const excludeList = exclude.map(fileURLToPath);
|
||||
const fileList = files.map(fileURLToPath).filter((f) => !excludeList.includes(f));
|
||||
const excludeList = exclude.map((url) => fileURLToPath(url));
|
||||
const fileList = files.map((url) => fileURLToPath(url)).filter((f) => !excludeList.includes(f));
|
||||
if (files.length === 0) throw new Error("No files found to copy");
|
||||
let commonAncestor = nodePath.dirname(fileList[0]);
|
||||
for (const file of fileList.slice(1)) {
|
||||
|
3
node_modules/@astrojs/internal-helpers/dist/path.d.ts
generated
vendored
3
node_modules/@astrojs/internal-helpers/dist/path.d.ts
generated
vendored
@@ -6,6 +6,8 @@ export declare function appendExtension(path: string, extension: string): string
|
||||
export declare function appendForwardSlash(path: string): string;
|
||||
export declare function prependForwardSlash(path: string): string;
|
||||
export declare function collapseDuplicateSlashes(path: string): string;
|
||||
export declare const MANY_TRAILING_SLASHES: RegExp;
|
||||
export declare function collapseDuplicateTrailingSlashes(path: string, trailingSlash: boolean): string;
|
||||
export declare function removeTrailingForwardSlash(path: string): string;
|
||||
export declare function removeLeadingForwardSlash(path: string): string;
|
||||
export declare function removeLeadingForwardSlashWindows(path: string): string;
|
||||
@@ -21,3 +23,4 @@ export declare function isRemotePath(src: string): boolean;
|
||||
export declare function slash(path: string): string;
|
||||
export declare function fileExtension(path: string): string;
|
||||
export declare function removeBase(path: string, base: string): string;
|
||||
export declare function hasFileExtension(path: string): boolean;
|
||||
|
14
node_modules/@astrojs/internal-helpers/dist/path.js
generated
vendored
14
node_modules/@astrojs/internal-helpers/dist/path.js
generated
vendored
@@ -10,6 +10,13 @@ function prependForwardSlash(path) {
|
||||
function collapseDuplicateSlashes(path) {
|
||||
return path.replace(/(?<!:)\/{2,}/g, "/");
|
||||
}
|
||||
const MANY_TRAILING_SLASHES = /\/{2,}$/g;
|
||||
function collapseDuplicateTrailingSlashes(path, trailingSlash) {
|
||||
if (!path) {
|
||||
return path;
|
||||
}
|
||||
return path.replace(MANY_TRAILING_SLASHES, trailingSlash ? "/" : "") || "/";
|
||||
}
|
||||
function removeTrailingForwardSlash(path) {
|
||||
return path.endsWith("/") ? path.slice(0, path.length - 1) : path;
|
||||
}
|
||||
@@ -77,11 +84,18 @@ function removeBase(path, base) {
|
||||
}
|
||||
return path;
|
||||
}
|
||||
const WITH_FILE_EXT = /\/[^/]+\.\w+$/;
|
||||
function hasFileExtension(path) {
|
||||
return WITH_FILE_EXT.test(path);
|
||||
}
|
||||
export {
|
||||
MANY_TRAILING_SLASHES,
|
||||
appendExtension,
|
||||
appendForwardSlash,
|
||||
collapseDuplicateSlashes,
|
||||
collapseDuplicateTrailingSlashes,
|
||||
fileExtension,
|
||||
hasFileExtension,
|
||||
isRelativePath,
|
||||
isRemotePath,
|
||||
joinPaths,
|
||||
|
62
node_modules/@astrojs/internal-helpers/dist/remote.d.ts
generated
vendored
Normal file
62
node_modules/@astrojs/internal-helpers/dist/remote.d.ts
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
export type RemotePattern = {
|
||||
hostname?: string;
|
||||
pathname?: string;
|
||||
protocol?: string;
|
||||
port?: string;
|
||||
};
|
||||
/**
|
||||
* Evaluates whether a given URL matches the specified remote pattern based on protocol, hostname, port, and pathname.
|
||||
*
|
||||
* @param {URL} url - The URL object to be matched against the remote pattern.
|
||||
* @param {RemotePattern} remotePattern - The remote pattern object containing the protocol, hostname, port, and pathname to match.
|
||||
* @return {boolean} Returns `true` if the URL matches the given remote pattern; otherwise, `false`.
|
||||
*/
|
||||
export declare function matchPattern(url: URL, remotePattern: RemotePattern): boolean;
|
||||
/**
|
||||
* Checks if the given URL's port matches the specified port. If no port is provided, it returns `true`.
|
||||
*
|
||||
* @param {URL} url - The URL object whose port will be checked.
|
||||
* @param {string} [port=] - The port to match against the URL's port. Optional.
|
||||
* @return {boolean} Returns `true` if the URL's port matches the specified port or if no port is provided; otherwise, `false`.
|
||||
*/
|
||||
export declare function matchPort(url: URL, port?: string): boolean;
|
||||
/**
|
||||
* Compares the protocol of the provided URL with a specified protocol.
|
||||
*
|
||||
* @param {URL} url - The URL object whose protocol needs to be checked.
|
||||
* @param {string} [protocol] - The protocol to compare against, without the trailing colon. If not provided, the method will always return `true`.
|
||||
* @return {boolean} Returns `true` if the protocol matches or if no protocol is specified; otherwise, `false`.
|
||||
*/
|
||||
export declare function matchProtocol(url: URL, protocol?: string): boolean;
|
||||
/**
|
||||
* Matches a given URL's hostname against a specified hostname, with optional support for wildcard patterns.
|
||||
*
|
||||
* @param {URL} url - The URL object whose hostname is to be matched.
|
||||
* @param {string} [hostname] - The hostname to match against. Supports wildcard patterns if `allowWildcard` is `true`.
|
||||
* @param {boolean} [allowWildcard=false] - Indicates whether wildcard patterns in the `hostname` parameter are allowed.
|
||||
* @return {boolean} - Returns `true` if the URL's hostname matches the given hostname criteria; otherwise, `false`.
|
||||
*/
|
||||
export declare function matchHostname(url: URL, hostname?: string, allowWildcard?: boolean): boolean;
|
||||
/**
|
||||
* Matches a given URL's pathname against a specified pattern, with optional support for wildcards.
|
||||
*
|
||||
* @param {URL} url - The URL object containing the pathname to be matched.
|
||||
* @param {string} [pathname] - The pathname pattern to match the URL against.
|
||||
* @param {boolean} [allowWildcard=false] - Determines whether wildcard matching is allowed.
|
||||
* @return {boolean} - Returns `true` if the URL's pathname matches the specified pattern; otherwise, `false`.
|
||||
*/
|
||||
export declare function matchPathname(url: URL, pathname?: string, allowWildcard?: boolean): boolean;
|
||||
/**
|
||||
* Determines whether a given remote resource, identified by its source URL,
|
||||
* is allowed based on specified domains and remote patterns.
|
||||
*
|
||||
* @param {string} src - The source URL of the remote resource to be validated.
|
||||
* @param {Object} options - The configuration options for domain and pattern matching.
|
||||
* @param {string[]} options.domains - A list of allowed domain names.
|
||||
* @param {RemotePattern[]} options.remotePatterns - A list of allowed remote patterns for matching.
|
||||
* @return {boolean} Returns `true` if the source URL matches any of the specified domains or remote patterns; otherwise, `false`.
|
||||
*/
|
||||
export declare function isRemoteAllowed(src: string, { domains, remotePatterns, }: {
|
||||
domains: string[];
|
||||
remotePatterns: RemotePattern[];
|
||||
}): boolean;
|
57
node_modules/@astrojs/internal-helpers/dist/remote.js
generated
vendored
Normal file
57
node_modules/@astrojs/internal-helpers/dist/remote.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
function matchPattern(url, remotePattern) {
|
||||
return matchProtocol(url, remotePattern.protocol) && matchHostname(url, remotePattern.hostname, true) && matchPort(url, remotePattern.port) && matchPathname(url, remotePattern.pathname, true);
|
||||
}
|
||||
function matchPort(url, port) {
|
||||
return !port || port === url.port;
|
||||
}
|
||||
function matchProtocol(url, protocol) {
|
||||
return !protocol || protocol === url.protocol.slice(0, -1);
|
||||
}
|
||||
function matchHostname(url, hostname, allowWildcard = false) {
|
||||
if (!hostname) {
|
||||
return true;
|
||||
} else if (!allowWildcard || !hostname.startsWith("*")) {
|
||||
return hostname === url.hostname;
|
||||
} else if (hostname.startsWith("**.")) {
|
||||
const slicedHostname = hostname.slice(2);
|
||||
return slicedHostname !== url.hostname && url.hostname.endsWith(slicedHostname);
|
||||
} else if (hostname.startsWith("*.")) {
|
||||
const slicedHostname = hostname.slice(1);
|
||||
const additionalSubdomains = url.hostname.replace(slicedHostname, "").split(".").filter(Boolean);
|
||||
return additionalSubdomains.length === 1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function matchPathname(url, pathname, allowWildcard = false) {
|
||||
if (!pathname) {
|
||||
return true;
|
||||
} else if (!allowWildcard || !pathname.endsWith("*")) {
|
||||
return pathname === url.pathname;
|
||||
} else if (pathname.endsWith("/**")) {
|
||||
const slicedPathname = pathname.slice(0, -2);
|
||||
return slicedPathname !== url.pathname && url.pathname.startsWith(slicedPathname);
|
||||
} else if (pathname.endsWith("/*")) {
|
||||
const slicedPathname = pathname.slice(0, -1);
|
||||
const additionalPathChunks = url.pathname.replace(slicedPathname, "").split("/").filter(Boolean);
|
||||
return additionalPathChunks.length === 1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function isRemoteAllowed(src, {
|
||||
domains,
|
||||
remotePatterns
|
||||
}) {
|
||||
if (!URL.canParse(src)) {
|
||||
return false;
|
||||
}
|
||||
const url = new URL(src);
|
||||
return domains.some((domain) => matchHostname(url, domain)) || remotePatterns.some((remotePattern) => matchPattern(url, remotePattern));
|
||||
}
|
||||
export {
|
||||
isRemoteAllowed,
|
||||
matchHostname,
|
||||
matchPathname,
|
||||
matchPattern,
|
||||
matchPort,
|
||||
matchProtocol
|
||||
};
|
Reference in New Issue
Block a user