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

More restrictive templateUrl and styleUrls regex #36

Open
ghetolay opened this issue Oct 20, 2016 · 2 comments
Open

More restrictive templateUrl and styleUrls regex #36

ghetolay opened this issue Oct 20, 2016 · 2 comments

Comments

@ghetolay
Copy link

ghetolay commented Oct 20, 2016

Hi,

In my code I'm currently dynamically creating component metadata and it's being replaced.
A more restrictive regex would avoid that.

/templateUrl\s*:\s*(['"`].*['"`])/g
/styleUrls\s*:(\s*\[.*['"`]+.*\])/g

Theses would be enough for me.
Introducing quote allows it to differentiate when we are using programmatic code like referencing to a variable and when we are statically setting an url through a string.

But maybe including '.html' or even checking for a preceding @component may be even better. Dunno if it's worth the trouble.

@daniel-a-melo
Copy link

I'm facing similar problem when using it with an hybrid ng1/ng4 app. It replaces templateUrl occurrences on ng1 templates, which it is unwanted behavior for this app.

Since it is an angular2-template-loader it would be better if it checked the occurrence within a @Component declaration

@MikeMatusz
Copy link

Also running into this issue with a hybrid app, where an Angular component needs to pass a templateUrl to an AngularJS component. Our AngularJS code uses it's existing build process to put all the templates in $templateCache keyed by their path, so checking for html wouldn't help, but an @component check would fix it. My current workaround is to assign the string to a variable and then assign the variable to templateUrl.

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

No branches or pull requests

3 participants