Skip to content

Simplify example of GulpBusterVersionStrategy #12587

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

Merged
merged 1 commit into from
Nov 6, 2019

Conversation

bocharsky-bw
Copy link
Contributor

@bocharsky-bw bocharsky-bw commented Nov 3, 2019

It seems we can simplify the code in applyVersion() or am I missing something?

Link to the related docs page:
https://symfony.com/doc/current/frontend/custom_version_strategy.html

@javiereguiluz
Copy link
Member

I don't know if both codes are equivalent in all cases ... but I think they are both wrong in the following case:

$format = '/%s/%s';
$path = '/foo';
$version = '3';

// Old code:
$versionized = '/foo/3';
return: '//foo/3'

// New code:
return: '//foo/3'

@bocharsky-bw
Copy link
Contributor Author

But you're using a different format /%s/%s. In this example, the default format is %s?%s, and the format we're using is %s?version=%s. If you expect a URL like /foo/3 - you need to use %s/%s format instead and the example will still work.

As I understand, this GulpBusterVersionStrategy is nothing more like just take some given path (and we expect the given path is correct, i.e. devs should care about what path to give /foo/bar or foo/bar) and adds a version of assets to it. I would not expect from this class that it adds the leading slash for me. Or it should always make sure the leading slash exist?

Copy link
Member

@javiereguiluz javiereguiluz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Victor, you are right. I didn't check the entire article. I agree that the format used in this example allows to make this refactorization 👍

@bocharsky-bw
Copy link
Contributor Author

OK, perfect. Thanks for the review, Javier!

@OskarStark
Copy link
Contributor

Thank you Victor.

OskarStark added a commit that referenced this pull request Nov 6, 2019
…-bw)

This PR was merged into the 3.4 branch.

Discussion
----------

Simplify example of GulpBusterVersionStrategy

It seems we can simplify the code in `applyVersion()` or am I missing something?

Link to the related docs page:
https://symfony.com/doc/current/frontend/custom_version_strategy.html

Commits
-------

8633bf1 Simplify example of GulpBusterVersionStrategy
@OskarStark OskarStark merged commit 8633bf1 into symfony:3.4 Nov 6, 2019
@bocharsky-bw bocharsky-bw deleted the patch-8 branch November 6, 2019 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants