-
Notifications
You must be signed in to change notification settings - Fork 89
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
Apply multiple route replacements to a resource #42
Comments
Example: exports.routes = [
{
from: new RegExp('^http://localhost/'),
to: 'src\/some.Web'
},
{
from: new RegExp('otherpartof/samepath/'),
to: ''
}
]; I use a tool that hashes the resources and changes the url to the items. I was hoping autosave would apply both route replacements before it tried to save the file. |
Looks like it goes off of the first match https://github.com/NV/chrome-devtools-autosave-server/blob/master/index.js#L72-73 It would be awesome if it would find all the matches and apply them in the order it finds them. |
I just sent a pull request with the change - NV/chrome-devtools-autosave-server#15 Thanks again for an awesome tool! |
Why, exactly, do you need a single resource to be saved in two different places?
I’m not following. What kind of tool is that? Also, see NV/chrome-devtools-autosave-server#11 |
Sorry for the confusion. Not saved to two different routes. Multiple route replacements applied to same resource. Take a look at the pull request I sent to the server project. |
I'm using cassette. It changes the url to resources to /_cassette/assets/resourcepath. |
Having it apply multiple route replacements would allow me to apply parts of replacements to multiple urls without having to repeat myself. |
I believe it could be done by using a single rule, e.g.: {
from: new RegExp('^http://localhost/(otherpartof/samepath/)?'),
to: 'src/some.Web'
} |
It could. But then I would do a copy paste change for new rules. Cleaner and simpler from a readability standpoint to have it apply each. And it makes for an easier maintenance aspect from the user perspective. And if the paths are not next to each other, do you allow for regex tag replacement? e.g: {
from: new RegExp('^http://localhost/(?<KEEP>somesection)/otherpart/of/samepath'),
to: 'src/somepath/${KEEP}'
} RegEx may not be completely valid, but I think it defines the gist. Up to you really. Pull request is there. |
Capture groups work, e.g.: {
from: new RegExp('^http://localhost/(somesection)/otherpart/of/samepath'),
to: 'src/somepath/$1'
} Although, JS doesn’t support named capture groups. I have to think some time about usefulness of your enhancement. |
Any word on this enhancement? I would like to do the capture groups mentioned above. |
I just want to say, autosave is one bad-a$$ tool. I am having a bit of an issue with multiple route replacements in the routes.js file.
The second one seems to be ignored...if I change the order, the one in the first spot now works.
The text was updated successfully, but these errors were encountered: