Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`snippet import snippet 1`] = `
<pre><code class="language-js">export default function () {
// ..
}
<pre><code># Sample snippet file with no filename extension.
FROM ubuntu:latest
CMD echo hello!
</code></pre>
`;

Expand Down
3 changes: 3 additions & 0 deletions packages/@vuepress/markdown/__tests__/fragments/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Sample snippet file with no filename extension.
FROM ubuntu:latest
CMD echo hello!
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<<< @/packages/@vuepress/markdown/__tests__/fragments/snippet.js
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep it, it would make sure import path with file extension works fine

<<< @/packages/@vuepress/markdown/__tests__/fragments/Dockerfile
2 changes: 1 addition & 1 deletion packages/@vuepress/markdown/lib/snippet.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ module.exports = function snippet (md, options = {}) {
*
* captures: ['/path/to/file.extension', 'extension', '#region', '{meta}']
*/
const rawPathRegexp = /^(.+(?:\.([a-z]+)))(?:(#[\w-]+))?(?: ?({\d+(?:[,-]\d+)*}))?$/
const rawPathRegexp = /^(.+?(?:\.([a-z]+))?)(?:(#[\w-]+))?(?: ?({\d+(?:[,-]\d+)*}))?$/

const rawPath = state.src.slice(start, end).trim().replace(/^@/, root).trim()
const [filename = '', extension = '', region = '', meta = ''] = (rawPathRegexp.exec(rawPath) || []).slice(1)
Expand Down