Skip to content

Custom "pathFromUrl" to remove digest/hash from asset filename #75

@steffenweber

Description

@steffenweber

First of all, thank you for implementing issue #17!

My asset hrefs contain a digest/hash, i.e. the main.css on disk is referenced as main.eec09356.css in the HTML (which is then rewritten to main.css by the webserver). The "changed" URL sent to livereload-js is just main.css. Therefore nothing matches with reloadMissingCSS = false.

I think I'd have to modify the pathFromUrl function to support this setup:

path = path.replace(/\.[0-9a-f]{8}\./, '.');

What would be the best way to make this feature optional / configurable such that it can be merged? Maybe a new pathFromUrl option that (if present) would be used instead of the default pathFromUrl function?

window.LiveReloadOptions = {
	pathFromUrl: function(url) {
		return url.replace(/\.[0-9a-f]{8}\./, '.');
	}
};

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