Commit 598952e
authored
feat: create injectable regex utility function (#536)
This PR introduces a new utility function, `createInjectableRegExp()`,
that converts any regex into an "injectable" version by removing its
leading `^` and trailing `$` anchors.
This is useful when you need to embed an existing pattern, which was
originally designed to match a whole string, inside another regex to
match it as a substring.
Thanks to this, we can replace
[APIFY_PROXY_VALUE_REGEX](https://github.com/apify/apify-shared-js/blob/master/packages/consts/src/regexs.ts#L51)
with
[REGEX_STR_USERNAME_VALUE](https://github.com/apify/apify-proxy/blob/develop/src/proxy_utils.ts#L20)
in Apify proxy and solve this issue
https://github.com/apify/apify-proxy/issues/1079.
The function was created in Apify shared repo, so it can be used in
other places.1 parent 916d84d commit 598952e
2 files changed
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
429 | 429 | | |
430 | 430 | | |
431 | 431 | | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
398 | 398 | | |
399 | 399 | | |
400 | 400 | | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
0 commit comments