Socket
Socket
Sign inDemoInstall

@vuepress/shared

Package Overview
Dependencies
Maintainers
2
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vuepress/shared - npm Package Compare versions

Comparing version 2.0.0-rc.11 to 2.0.0-rc.12

74

dist/index.d.ts

@@ -185,56 +185,69 @@ import { MarkdownItHeader } from '@mdit-vue/types';

/**
* Dedupe head config with identifier
* Determine a link is external or not
*/
declare const isLinkExternal: (link: string, base?: string) => boolean;
/**
* Determine a link is http link or not
*
* Items that appear earlier have higher priority
* - http://github.com
* - https://github.com
* - //github.com
*/
declare const dedupeHead: (head: HeadConfig[]) => HeadConfig[];
declare const isLinkHttp: (link: string) => boolean;
/**
* Ensure a url string to have leading slash /
* Determine a link has protocol or not
*/
declare const ensureLeadingSlash: (str: string) => string;
declare const isLinkWithProtocol: (link: string) => boolean;
/**
* Ensure a url string to have ending slash /
* Infer route path according to the given (markdown file) path
*/
declare const ensureEndingSlash: (str: string) => string;
declare const inferRoutePath: (path: string) => string;
/**
* Format a date string to `yyyy-MM-dd`
* Normalize the given pathname path to the final route path
*/
declare const formatDateString: (str: string, defaultDateString?: string) => string;
declare const normalizeRoutePath: (pathname: string, current?: string) => string;
/**
* Infer route path according to the given (markdown file) path
* Resolve the matched locale path of route path
*/
declare const inferRoutePath: (path: string) => string;
declare const resolveLocalePath: (locales: LocaleConfig, routePath: string) => string;
/**
* Determine a link is external or not
* For a give URL, remove the origin and the site base to get the route path
*/
declare const isLinkExternal: (link: string, base?: string) => boolean;
declare const resolveRoutePathFromUrl: (url: string, base?: string) => string;
/**
* Determine a link is http link or not
* Split a path into pathname and hashAndQueries
*/
declare const splitPath: (path: string) => {
pathname: string;
hashAndQueries: string;
};
/**
* Dedupe head config with identifier
*
* - http://github.com
* - https://github.com
* - //github.com
* Items that appear earlier have higher priority
*/
declare const isLinkHttp: (link: string) => boolean;
declare const dedupeHead: (head: HeadConfig[]) => HeadConfig[];
/**
* Determine a link has protocol or not
* Ensure a url string to have leading slash /
*/
declare const isLinkWithProtocol: (link: string) => boolean;
declare const ensureLeadingSlash: (str: string) => string;
/**
* Check if a value is plain object, with generic type support
* Ensure a url string to have ending slash /
*/
declare const isPlainObject: <T extends Record<any, any> = Record<any, any>>(val: unknown) => val is T;
declare const ensureEndingSlash: (str: string) => string;
/**
* Normalize the given path to the final route path
* Format a date string to `yyyy-MM-dd`
*/
declare const normalizeRoutePath: (path: string, current?: string) => string;
declare const formatDateString: (str: string, defaultDateString?: string) => string;

@@ -262,9 +275,2 @@ /**

/**
* Resolve the matched locale path of route path
*/
declare const resolveLocalePath: (locales: LocaleConfig, routePath: string) => string;
declare const resolveRoutePathFromUrl: (url: string, base?: string) => string;
/**
* Check if a value is a function

@@ -274,2 +280,6 @@ */

/**
* Check if a value is plain object, with generic type support
*/
declare const isPlainObject: <T extends Record<any, any> = Record<any, any>>(val: unknown) => val is T;
/**
* Check if a value is a string

@@ -279,2 +289,2 @@ */

export { type HeadAttrsConfig, type HeadConfig, type HeadTag, type HeadTagEmpty, type HeadTagNonEmpty, type LocaleConfig, type LocaleData, type PageBase, type PageData, type PageFrontmatter, type PageHeader, type SiteData, type SiteLocaleConfig, type SiteLocaleData, type VuepressSSRContext, dedupeHead, ensureEndingSlash, ensureLeadingSlash, formatDateString, inferRoutePath, isFunction, isLinkExternal, isLinkHttp, isLinkWithProtocol, isPlainObject, isString, normalizeRoutePath, omit, removeEndingSlash, removeLeadingSlash, resolveHeadIdentifier, resolveLocalePath, resolveRoutePathFromUrl };
export { type HeadAttrsConfig, type HeadConfig, type HeadTag, type HeadTagEmpty, type HeadTagNonEmpty, type LocaleConfig, type LocaleData, type PageBase, type PageData, type PageFrontmatter, type PageHeader, type SiteData, type SiteLocaleConfig, type SiteLocaleData, type VuepressSSRContext, dedupeHead, ensureEndingSlash, ensureLeadingSlash, formatDateString, inferRoutePath, isFunction, isLinkExternal, isLinkHttp, isLinkWithProtocol, isPlainObject, isString, normalizeRoutePath, omit, removeEndingSlash, removeLeadingSlash, resolveHeadIdentifier, resolveLocalePath, resolveRoutePathFromUrl, splitPath };

@@ -0,1 +1,71 @@

// src/utils/links/isLinkWithProtocol.ts
var isLinkWithProtocol = (link) => /^[a-z][a-z0-9+.-]*:/.test(link) || link.startsWith("//");
// src/utils/links/isLinkExternal.ts
var markdownLinkRegexp = /.md((\?|#).*)?$/;
var isLinkExternal = (link, base = "/") => isLinkWithProtocol(link) || // absolute link that does not start with `base` and does not end with `.md`
link.startsWith("/") && !link.startsWith(base) && !markdownLinkRegexp.test(link);
// src/utils/links/isLinkHttp.ts
var isLinkHttp = (link) => /^(https?:)?\/\//.test(link);
// src/utils/routes/inferRoutePath.ts
var inferRoutePath = (path) => {
if (!path || path.endsWith("/"))
return path;
let routePath = path.replace(/(^|\/)README.md$/i, "$1index.html");
if (routePath.endsWith(".md")) {
routePath = routePath.substring(0, routePath.length - 3) + ".html";
} else if (!routePath.endsWith(".html")) {
routePath = routePath + ".html";
}
if (routePath.endsWith("/index.html")) {
routePath = routePath.substring(0, routePath.length - 10);
}
return routePath;
};
// src/utils/routes/normalizeRoutePath.ts
var FAKE_HOST = "http://.";
var normalizeRoutePath = (pathname, current) => {
if (!pathname.startsWith("/") && current) {
const loc = current.slice(0, current.lastIndexOf("/"));
return inferRoutePath(new URL(`${loc}/${pathname}`, FAKE_HOST).pathname);
}
return inferRoutePath(pathname);
};
// src/utils/routes/resolveLocalePath.ts
var resolveLocalePath = (locales, routePath) => {
const localePaths = Object.keys(locales).sort((a, b) => {
const levelDelta = b.split("/").length - a.split("/").length;
if (levelDelta !== 0) {
return levelDelta;
}
return b.length - a.length;
});
for (const localePath of localePaths) {
if (routePath.startsWith(localePath)) {
return localePath;
}
}
return "/";
};
// src/utils/routes/resolveRoutePathFromUrl.ts
var resolveRoutePathFromUrl = (url, base = "/") => {
const pathname = url.replace(/^(?:https?:)?\/\/[^/]*/, "");
return pathname.startsWith(base) ? `/${pathname.slice(base.length)}` : pathname;
};
// src/utils/routes/splitPath.ts
var SPLIT_CHAR_REGEXP = /(#|\?)/;
var splitPath = (path) => {
const [pathname, ...hashAndQueries] = path.split(SPLIT_CHAR_REGEXP);
return {
pathname,
hashAndQueries: hashAndQueries.join("")
};
};
// src/utils/resolveHeadIdentifier.ts

@@ -59,44 +129,2 @@ var TAGS_ALLOWED = ["link", "meta", "script", "style", "noscript", "template"];

// src/utils/inferRoutePath.ts
var inferRoutePath = (path) => {
if (!path || path.endsWith("/"))
return path;
let routePath = path.replace(/(^|\/)README.md$/i, "$1index.html");
if (routePath.endsWith(".md")) {
routePath = routePath.substring(0, routePath.length - 3) + ".html";
} else if (!routePath.endsWith(".html")) {
routePath = routePath + ".html";
}
if (routePath.endsWith("/index.html")) {
routePath = routePath.substring(0, routePath.length - 10);
}
return routePath;
};
// src/utils/isLinkWithProtocol.ts
var isLinkWithProtocol = (link) => /^[a-z][a-z0-9+.-]*:/.test(link) || link.startsWith("//");
// src/utils/isLinkExternal.ts
var markdownLinkRegexp = /.md((\?|#).*)?$/;
var isLinkExternal = (link, base = "/") => isLinkWithProtocol(link) || // absolute link that does not start with `base` and does not end with `.md`
link.startsWith("/") && !link.startsWith(base) && !markdownLinkRegexp.test(link);
// src/utils/isLinkHttp.ts
var isLinkHttp = (link) => /^(https?:)?\/\//.test(link);
// src/utils/isPlainObject.ts
var isPlainObject = (val) => Object.prototype.toString.call(val) === "[object Object]";
// src/utils/normalizeRoutePath.ts
var FAKE_HOST = "http://.";
var normalizeRoutePath = (path, current) => {
if (!path.startsWith("/") && current) {
const loc = current.slice(0, current.lastIndexOf("/"));
const { pathname: pathname2, search, hash } = new URL(`${loc}/${path}`, FAKE_HOST);
return inferRoutePath(pathname2) + search + hash;
}
const [pathname, ...queryAndHash] = path.split(/(\?|#)/);
return inferRoutePath(pathname) + queryAndHash.join("");
};
// src/utils/omit.ts

@@ -117,27 +145,5 @@ var omit = (obj, ...keys) => {

// src/utils/resolveLocalePath.ts
var resolveLocalePath = (locales, routePath) => {
const localePaths = Object.keys(locales).sort((a, b) => {
const levelDelta = b.split("/").length - a.split("/").length;
if (levelDelta !== 0) {
return levelDelta;
}
return b.length - a.length;
});
for (const localePath of localePaths) {
if (routePath.startsWith(localePath)) {
return localePath;
}
}
return "/";
};
// src/utils/resolveRoutePathFromUrl.ts
var resolveRoutePathFromUrl = (url, base = "/") => {
const pathname = url.replace(/^(?:https?:)?\/\/[^/]*/, "");
return pathname.startsWith(base) ? `/${pathname.slice(base.length)}` : pathname;
};
// src/utils/typeGuards.ts
var isFunction = (val) => typeof val === "function";
var isPlainObject = (val) => Object.prototype.toString.call(val) === "[object Object]";
var isString = (val) => typeof val === "string";

@@ -162,3 +168,4 @@ export {

resolveLocalePath,
resolveRoutePathFromUrl
resolveRoutePathFromUrl,
splitPath
};
{
"name": "@vuepress/shared",
"version": "2.0.0-rc.11",
"version": "2.0.0-rc.12",
"description": "Utils that shared between VuePress node and client",

@@ -5,0 +5,0 @@ "keywords": [

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