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.9 to 2.0.0-rc.10

11

dist/index.d.ts

@@ -88,3 +88,3 @@ import { MarkdownItHeader } from '@mdit-vue/types';

layout?: string;
permalink?: string;
permalink?: string | null;
permalinkPattern?: string | null;

@@ -208,2 +208,7 @@ routeMeta?: Record<string, unknown>;

/**
* Infer route path according to the given (markdown file) path
*/
declare const inferRoutePath: (path: string) => string;
/**
* Determine a link is external or not

@@ -235,3 +240,3 @@ */

*/
declare const normalizeRoutePath: (path: string) => string;
declare const normalizeRoutePath: (path: string, current?: string) => string;

@@ -274,2 +279,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, 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 };

@@ -59,20 +59,29 @@ // src/utils/resolveHeadIdentifier.ts

// src/utils/isLinkHttp.ts
var isLinkHttp = (link) => /^(https?:)?\/\//.test(link);
// src/utils/isLinkExternal.ts
var markdownLinkRegexp = /.md((\?|#).*)?$/;
var isLinkExternal = (link, base = "/") => {
if (isLinkHttp(link)) {
return true;
// 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 (link.startsWith("/") && !link.startsWith(base) && !markdownLinkRegexp.test(link)) {
return true;
if (routePath.endsWith("/index.html")) {
routePath = routePath.substring(0, routePath.length - 10);
}
return false;
return routePath;
};
// src/utils/isLinkWithProtocol.ts
var isLinkWithProtocol = (link) => /^[a-z][a-z0-9+.-]*:/.test(link);
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

@@ -82,16 +91,11 @@ var isPlainObject = (val) => Object.prototype.toString.call(val) === "[object Object]";

// src/utils/normalizeRoutePath.ts
var normalizeRoutePath = (path) => {
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(/(\?|#)/);
if (!pathname || pathname.endsWith("/"))
return path;
let routePath = pathname.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 + queryAndHash.join("");
return inferRoutePath(pathname) + queryAndHash.join("");
};

@@ -133,3 +137,3 @@

var resolveRoutePathFromUrl = (url, base = "/") => {
const pathname = url.replace(/^(https?:)?\/\/[^/]*/, "");
const pathname = url.replace(/^(?:https?:)?\/\/[^/]*/, "");
return pathname.startsWith(base) ? `/${pathname.slice(base.length)}` : pathname;

@@ -146,2 +150,3 @@ };

formatDateString,
inferRoutePath,
isFunction,

@@ -148,0 +153,0 @@ isLinkExternal,

{
"name": "@vuepress/shared",
"version": "2.0.0-rc.9",
"version": "2.0.0-rc.10",
"description": "Utils that shared between VuePress node and client",

@@ -32,3 +32,3 @@ "keywords": [

"dependencies": {
"@mdit-vue/types": "^2.0.0"
"@mdit-vue/types": "^2.1.0"
},

@@ -35,0 +35,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