-
-
Notifications
You must be signed in to change notification settings - Fork 20
Fix filesystem path loading #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| div.foo{color:red} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <link rel="stylesheet" href="./style.css"/> | ||
| <title>Access external stylesheet from FS</title> | ||
| </head> | ||
| <body> | ||
| <div class="foo"> | ||
| <h1>Access external stylesheet from FS</h1> | ||
| </div> | ||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -197,3 +197,13 @@ describe('options', () => { | |
| }) | ||
| }) | ||
| }) | ||
|
|
||
| describe('accessing file system', () => { | ||
| it('works', async () => { | ||
| const output = await compileToHtml('fs-access', configure, { | ||
| path: './dist/', | ||
| publicPath: '', | ||
| }) | ||
| expect(output.html).toMatch(/\.foo/) | ||
| }) | ||
| }) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Enhance test coverage for filesystem path handling The current test suite could benefit from more comprehensive coverage, particularly given the Windows path handling issues mentioned in PR #29. Consider adding these test cases:
Here's a suggested enhancement: describe('accessing file system', () => {
it('works', async () => {
const output = await compileToHtml('fs-access', configure, {
path: './dist/',
publicPath: '',
})
expect(output.html).toMatch(/\.foo/)
})
+
+ it('handles Windows-style paths', async () => {
+ const output = await compileToHtml('fs-access', configure, {
+ path: '.\\dist\\',
+ publicPath: '',
+ })
+ expect(output.html).toMatch(/\.foo/)
+ })
+
+ it('handles absolute paths', async () => {
+ const output = await compileToHtml('fs-access', configure, {
+ path: path.resolve(__dirname, 'dist'),
+ publicPath: '',
+ })
+ expect(output.html).toMatch(/\.foo/)
+ })
+
+ it('handles missing stylesheet gracefully', async () => {
+ await expect(compileToHtml('fs-access', configure, {
+ path: './non-existent/',
+ publicPath: '',
+ })).rejects.toThrow()
+ })
})
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Hard-coded Path Separators Detected
The path handling implementation includes hard-coded path separators which may not resolve correctly across different platforms.
packages/beasties/test/beasties.test.tspackages/beasties/test/beasties.bench.tspackages/beasties/test/security.test.tspackages/beasties/src/util.tspackages/beasties-webpack-plugin/test/index.test.tspackages/beasties-webpack-plugin/test/standalone.test.tspackages/beasties-webpack-plugin/test/helpers.tspackages/beasties/src/types.tspackages/beasties/src/index.d.tspackages/beasties/src/dom.tspackages/beasties/src/index.tspackages/beasties/src/css.ts🔗 Analysis chain
Verify path handling implementation
Let's verify that the path handling implementation correctly resolves paths across different platforms.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 1666
Script:
Length of output: 526
Script:
Length of output: 453
Script:
Length of output: 549
Script:
Length of output: 1123