karma-runner / karma-runner/karma

Encode special characters in file paths

Open
#1,335 0 comments 0 reactions 0 assignees View on GitHub
type: backlog
Dominant language
JavaScript
Stars
12k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

Karma doesn't encode special characters in file paths, which causes 404 errors if any of your files contain special characters.

For example, create a folder named `({[ ! % & $ # @` ~ ,)}]`, and inside that folder, create a file named`({[ ! % & $ # @ `~ ,)}].js`. Now configure your `karma.conf.js` file to serve this file:

``` javascript
module.exports = function(config) {
config.set({
files: [
'({[ ! % & $ # @ ` ~ ,)}]/({[ ! % & $ # @ ` ~ ,)}].js'
]
});
};
```

Now try running your tests. You'll get a 404 error, because Karma adds the following `` tag to the page, which the browser is unable to resolve.

``` html
<script type="text/javascript" src="/base/({[ ! % & $ # @ ` ~ ,)}]/({[ ! % & $ # @ ` ~ ,)}].js">
```

Instead, the `` tag should look like this:

``` html
<script type="text/javascript" src="/base/(%7B%5B%20!%20%25%20%26%20%24%20%23%20%40%20%60%20~%20%2C)%7D%5D/(%7B%5B%20!%20%25%20%26%20%24%20%23%20%40%20%60%20~%20%2C)%7D%5D.js">
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.