Skip to content
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

rewriteRules with { match: regex, replace:'$1' } seems broken #1008

Open
1 task done
fvsch opened this issue Feb 19, 2016 · 1 comment
Open
1 task done

rewriteRules with { match: regex, replace:'$1' } seems broken #1008

fvsch opened this issue Feb 19, 2016 · 1 comment

Comments

@fvsch
Copy link

fvsch commented Feb 19, 2016

Issue details

I can't get rewrite rules such as:

{ match: /some (stuff)/, replace: 'hot $1' }

to replace the $1 like String.prototype.replace does. The resulting string always keeps the $1.

This is surprising, since using $1 is advertised in:
https://www.browsersync.io/docs/options/#option-rewriteRules
https://github.com/BrowserSync/browser-sync/blob/master/examples/proxy.rewriteRules.advanced.js

Steps to reproduce/test case

  1. bs-config.js:

    module.exports = {
      proxy: 'example.com',
      rewriteRules: [
        { match: /(<!doctype html>)/i, replace: '<!-- $1 -->' }
      ]
    }
  2. Run browser-sync start --config=bs-config.js.

  3. See the HTML source: doctype is replaced by <!-- $1 -->.

Please specify which version of Browsersync, node and npm you're running

Tried on two computers:

  • Windows 10, Browsersync 2.11.1, npm 2.14.3, Node 4.1.0
  • OSX 10.11.3, Browsersync 2.11.1, npm 3.7.2, Node 5.6.0

Browsersync use-case

  • CLI

Only tried with CLI + config file. Might impact other use cases too.

@shakyShane shakyShane added the bug label Apr 6, 2016
@shakyShane
Copy link
Contributor

thanks @fvsch this is indeed a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants