Skip to content

Source hostname:port rewriting clobbers attributes when using simple hostname #1023

@quinncomendant

Description

@quinncomendant

This might be a wontfix, and if so I would encourage at least to add a note regarding this issue to the documentation (perhaps it's already there; I couldn't find it).

Issue details

When using a simple hostname for proxy, e.g., --proxy d:80 (here, d is the hostname of our local development server, as defined in my /etc/hosts: 192.168.64.24 d), browser-sync will rewrite all matching occurrences in the HTML source, e.g., class="dropdown" becomes class="localhost:3000ropdown".

Longer example: a snippet of code when loaded directly at http://d./page/:

<ul class="dropdown">
    <li>foo</li>
    <li class="divider"></li>
    <li>bar</li>
    <li class="divider"></li>
    <li>baz</li>
</ul>

And the same snippet, proxied via browser-sync running at localhost at http://localhost:3000/page/:

<ul class="localhost:3000ropdown">
    <li>foo</li>
    <li class="localhost:3000ivider"></li>
    <li>bar</li>
    <li class="localhost:3000ivider"></li>
    <li>baz</li>
</ul>

I tried to solve the problem by using --proxy http://d:80 but that didn't seem to change the source rewriting matching pattern. The only solution is to use a more unique hostname for the development server, which will not match any existing HTML attributes, e.g., --proxy mydevserver.local:80.

It's my fault for using such as short hostname (d), but I thought I would create a ticket just in case it helps others who experience the same problem.

Steps to reproduce/test case

Use a simple hostname for the --proxy option that resolves to your development server (e.g., --proxy d:80), and which also matches existing class names used in HTML attributes (e.g., class="dropdown").

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

  • Browsersync [ 2.11.1 ]
  • Node [ 5.7.0 ]
  • Npm [ 3.6.0 ]

Affected platforms

  • [ X ] OS X

Browsersync use-case

  • [ X ] CLI

If CLI, please paste the entire command below

browser-sync start --no-online --no-open --no-notify --no-ghost-mode --proxy d:80 --files '*.php, assets/build/*'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions