diff options
author | 2022-12-22 10:38:03 -0500 | |
---|---|---|
committer | 2022-12-22 10:38:03 -0500 | |
commit | 853081d1c857d8ad8a9634c37ed8fd123d32d241 (patch) | |
tree | 39bbad51f665c2f771fc0d9900656e7d09640b76 /packages/integrations/mdx/src/utils.ts | |
parent | b64081deed88271a4aa55d66468a10fea235e0a9 (diff) | |
download | astro-853081d1c857d8ad8a9634c37ed8fd123d32d241.tar.gz astro-853081d1c857d8ad8a9634c37ed8fd123d32d241.tar.zst astro-853081d1c857d8ad8a9634c37ed8fd123d32d241.zip |
[Content] Throw on relative image usage (#5648)
* chore: add rel image error plugin
* deps: mdast, mdast types
* chore: add rel image throw to mdx
* refactor: doc rel image path plugin
* fix: respect experimental flag in md remark
* chore: changeset
* deps: remove mdast package
* fix: resolve contentDir from config
* fix: apply MDX plugin after user plugins
* fix: stub out contentDir
Diffstat (limited to 'packages/integrations/mdx/src/utils.ts')
-rw-r--r-- | packages/integrations/mdx/src/utils.ts | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/packages/integrations/mdx/src/utils.ts b/packages/integrations/mdx/src/utils.ts index 60a50c85a..e803dc300 100644 --- a/packages/integrations/mdx/src/utils.ts +++ b/packages/integrations/mdx/src/utils.ts @@ -95,3 +95,22 @@ export function handleExtendsNotSupported(pluginConfig: any) { ); } } + +// Following utils taken from `packages/astro/src/core/path.ts`: + +export function isRelativePath(path: string) { + return startsWithDotDotSlash(path) || startsWithDotSlash(path); +} + +function startsWithDotDotSlash(path: string) { + const c1 = path[0]; + const c2 = path[1]; + const c3 = path[2]; + return c1 === '.' && c2 === '.' && c3 === '/'; +} + +function startsWithDotSlash(path: string) { + const c1 = path[0]; + const c2 = path[1]; + return c1 === '.' && c2 === '/'; +} |