@rspress/shared 0.0.0-next-20231115072918 → 0.0.0-next-20231207111357

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -685,7 +685,8 @@ declare function removeLeadingSlash(url: string): string;
685
685
  declare function addTrailingSlash(url: string): string;
686
686
  declare function removeTrailingSlash(url: string): string;
687
687
  declare function normalizeSlash(url: string): string;
688
- declare function isExternalUrl(url: string): boolean;
688
+ declare function isExternalUrl(url?: string): boolean;
689
+ declare function isDataUrl(url?: string): boolean;
689
690
  declare function replaceLang(rawUrl: string, lang: {
690
691
  current: string;
691
692
  target: string;
@@ -714,4 +715,4 @@ declare function removeBase(url: string, base: string): string;
714
715
  declare function withoutHash(url: string): string;
715
716
  declare const mergeDocConfig: (...configs: UserConfig[]) => UserConfig;
716
717
 
717
- export { APPEARANCE_KEY, AdditionalPage, BaseRuntimePageInfo, Config, DEFAULT_HIGHLIGHT_LANGUAGES, Config$1 as DefaultThemeConfig, DocFooter, EditLink, Feature, Footer, FrontMatterMeta, HASH_REGEXP, Header, Hero, Image, LocalSearchOptions, Locale, LocaleConfig, LocaleLink, LocaleLinks, MDX_REGEXP, MarkdownOptions, Nav, NavItem, NavItemWithChildren, NavItemWithLink, NavItemWithLinkAndChildren, NormalizedConfig, NormalizedConfig as NormalizedDefaultThemeConfig, NormalizedLocales, NormalizedSidebar, NormalizedSidebarGroup, PageData, PageIndexInfo, PageModule, PageType, RspressPlugin as Plugin, QUERY_REGEXP, RSPRESS_TEMP_DIR, RemotePageInfo, RemoteSearchIndexInfo, RemoteSearchOptions, ReplaceRule, Route, RouteMeta, RouteOptions, RspressPlugin, SEARCH_INDEX_NAME, SearchHooks, SearchOptions, Sidebar, SidebarDivider, SidebarGroup, SidebarItem, SiteData, SocialLink, SocialLinkIcon, UserConfig, addLeadingSlash, addTrailingSlash, cleanUrl, inBrowser, isDebugMode, isExternalUrl, isProduction, isSCM, mergeDocConfig, normalizeHref, normalizePosixPath, normalizeSlash, omit, parseUrl, removeBase, removeHash, removeLeadingSlash, removeTrailingSlash, replaceLang, replaceVersion, slash, withBase, withoutBase, withoutHash, withoutLang };
718
+ export { APPEARANCE_KEY, AdditionalPage, BaseRuntimePageInfo, Config, DEFAULT_HIGHLIGHT_LANGUAGES, Config$1 as DefaultThemeConfig, DocFooter, EditLink, Feature, Footer, FrontMatterMeta, HASH_REGEXP, Header, Hero, Image, LocalSearchOptions, Locale, LocaleConfig, LocaleLink, LocaleLinks, MDX_REGEXP, MarkdownOptions, Nav, NavItem, NavItemWithChildren, NavItemWithLink, NavItemWithLinkAndChildren, NormalizedConfig, NormalizedConfig as NormalizedDefaultThemeConfig, NormalizedLocales, NormalizedSidebar, NormalizedSidebarGroup, PageData, PageIndexInfo, PageModule, PageType, RspressPlugin as Plugin, QUERY_REGEXP, RSPRESS_TEMP_DIR, RemotePageInfo, RemoteSearchIndexInfo, RemoteSearchOptions, ReplaceRule, Route, RouteMeta, RouteOptions, RspressPlugin, SEARCH_INDEX_NAME, SearchHooks, SearchOptions, Sidebar, SidebarDivider, SidebarGroup, SidebarItem, SiteData, SocialLink, SocialLinkIcon, UserConfig, addLeadingSlash, addTrailingSlash, cleanUrl, inBrowser, isDataUrl, isDebugMode, isExternalUrl, isProduction, isSCM, mergeDocConfig, normalizeHref, normalizePosixPath, normalizeSlash, omit, parseUrl, removeBase, removeHash, removeLeadingSlash, removeTrailingSlash, replaceLang, replaceVersion, slash, withBase, withoutBase, withoutHash, withoutLang };
package/dist/index.js CHANGED
@@ -31,6 +31,7 @@ __export(src_exports, {
31
31
  addTrailingSlash: () => addTrailingSlash,
32
32
  cleanUrl: () => cleanUrl,
33
33
  inBrowser: () => inBrowser,
34
+ isDataUrl: () => isDataUrl,
34
35
  isDebugMode: () => isDebugMode,
35
36
  isExternalUrl: () => isExternalUrl,
36
37
  isProduction: () => isProduction,
@@ -1183,9 +1184,12 @@ function removeTrailingSlash(url) {
1183
1184
  function normalizeSlash(url) {
1184
1185
  return removeTrailingSlash(addLeadingSlash(normalizePosixPath(url)));
1185
1186
  }
1186
- function isExternalUrl(url) {
1187
+ function isExternalUrl(url = "") {
1187
1188
  return url.startsWith("http://") || url.startsWith("https://") || url.startsWith("mailto:") || url.startsWith("tel:");
1188
1189
  }
1190
+ function isDataUrl(url = "") {
1191
+ return /^\s*data:/i.test(url);
1192
+ }
1189
1193
  function replaceLang(rawUrl, lang, version, base = "") {
1190
1194
  let url = removeBase(rawUrl, base);
1191
1195
  if (!url) {
@@ -1266,9 +1270,6 @@ function normalizeHref(url, cleanUrls = false) {
1266
1270
  return url;
1267
1271
  }
1268
1272
  let { url: cleanUrl2, hash } = parseUrl(decodeURIComponent(url));
1269
- if (url.startsWith("mailto:") || url.startsWith("tel:")) {
1270
- return url;
1271
- }
1272
1273
  const hasExt = cleanUrl2.split("/").pop()?.includes(".");
1273
1274
  if (!cleanUrls && !cleanUrl2.endsWith(".html") && !hasExt) {
1274
1275
  if (cleanUrl2.endsWith("/")) {
@@ -1277,6 +1278,9 @@ function normalizeHref(url, cleanUrls = false) {
1277
1278
  cleanUrl2 += ".html";
1278
1279
  }
1279
1280
  }
1281
+ if (cleanUrls && cleanUrl2.endsWith("/")) {
1282
+ cleanUrl2 += "index";
1283
+ }
1280
1284
  return addLeadingSlash(hash ? `${cleanUrl2}#${hash}` : cleanUrl2);
1281
1285
  }
1282
1286
  function withoutLang(path, langs) {
@@ -1323,6 +1327,7 @@ var mergeDocConfig = (...configs) => mergeWith_default({}, ...configs, (target,
1323
1327
  addTrailingSlash,
1324
1328
  cleanUrl,
1325
1329
  inBrowser,
1330
+ isDataUrl,
1326
1331
  isDebugMode,
1327
1332
  isExternalUrl,
1328
1333
  isProduction,
package/dist/index.mjs CHANGED
@@ -1126,9 +1126,12 @@ function removeTrailingSlash(url) {
1126
1126
  function normalizeSlash(url) {
1127
1127
  return removeTrailingSlash(addLeadingSlash(normalizePosixPath(url)));
1128
1128
  }
1129
- function isExternalUrl(url) {
1129
+ function isExternalUrl(url = "") {
1130
1130
  return url.startsWith("http://") || url.startsWith("https://") || url.startsWith("mailto:") || url.startsWith("tel:");
1131
1131
  }
1132
+ function isDataUrl(url = "") {
1133
+ return /^\s*data:/i.test(url);
1134
+ }
1132
1135
  function replaceLang(rawUrl, lang, version, base = "") {
1133
1136
  let url = removeBase(rawUrl, base);
1134
1137
  if (!url) {
@@ -1209,9 +1212,6 @@ function normalizeHref(url, cleanUrls = false) {
1209
1212
  return url;
1210
1213
  }
1211
1214
  let { url: cleanUrl2, hash } = parseUrl(decodeURIComponent(url));
1212
- if (url.startsWith("mailto:") || url.startsWith("tel:")) {
1213
- return url;
1214
- }
1215
1215
  const hasExt = cleanUrl2.split("/").pop()?.includes(".");
1216
1216
  if (!cleanUrls && !cleanUrl2.endsWith(".html") && !hasExt) {
1217
1217
  if (cleanUrl2.endsWith("/")) {
@@ -1220,6 +1220,9 @@ function normalizeHref(url, cleanUrls = false) {
1220
1220
  cleanUrl2 += ".html";
1221
1221
  }
1222
1222
  }
1223
+ if (cleanUrls && cleanUrl2.endsWith("/")) {
1224
+ cleanUrl2 += "index";
1225
+ }
1223
1226
  return addLeadingSlash(hash ? `${cleanUrl2}#${hash}` : cleanUrl2);
1224
1227
  }
1225
1228
  function withoutLang(path, langs) {
@@ -1265,6 +1268,7 @@ export {
1265
1268
  addTrailingSlash,
1266
1269
  cleanUrl,
1267
1270
  inBrowser,
1271
+ isDataUrl,
1268
1272
  isDebugMode,
1269
1273
  isExternalUrl,
1270
1274
  isProduction,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/shared",
3
- "version": "0.0.0-next-20231115072918",
3
+ "version": "0.0.0-next-20231207111357",
4
4
  "types": "./dist/index.d.ts",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -22,7 +22,7 @@
22
22
  }
23
23
  },
24
24
  "dependencies": {
25
- "@rsbuild/core": "0.0.0-next-20231115072032",
25
+ "@rsbuild/core": "0.0.0-next-20231207110454",
26
26
  "unified": "10.1.2",
27
27
  "chalk": "4.1.2",
28
28
  "rslog": "^1.1.0"
@@ -47,6 +47,7 @@
47
47
  "provenance": true,
48
48
  "registry": "https://registry.npmjs.org/"
49
49
  },
50
+ "license": "MIT",
50
51
  "files": [
51
52
  "bin",
52
53
  "dist"