karma-runner / karma-runner/karma

Allow regular expressions in proxies definition

Open
#1,930 2 comments 6 reactions 0 assignees View on GitHub
discuss help wanted type: feature
Dominant language
JavaScript
Stars
12k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

### Wished behavior

I would like to be able to tell Karma to serve a file whatever the sub-path is.
I could also want to transform the URL to something completely different.
For instance, something like this (but it won't work with the object syntax):

``` javascript
proxies: {
/\/images\/.*/: "/base/test/assets/placeholder.png",
/\/books/(\d+)\/pages\/(\d+)/: "http://external.host/get_book_page.php?book_id=$1&page_id=$2"
}
```
### Proposed syntax

`proxies` could accept an object, as it is currently the case, or an array of arrays, which is still readable, and accepts regular expressions as "keys":

``` javascript
proxies: [
[/\/images\/.*/, "/base/test/assets/placeholder.png"],
[/\/books/(\d+)\/pages\/(\d+)/, "http://external.host/get_book_page.php?book_id=$1&page_id=$2"]
]
```

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.