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

rebaseRelativeTo fixes #27

Merged
merged 4 commits into from
Mar 6, 2017
Merged

rebaseRelativeTo fixes #27

merged 4 commits into from
Mar 6, 2017

Conversation

seyfert
Copy link
Contributor

@seyfert seyfert commented Feb 28, 2017

Found two issues while trying to use the rebaseRelativeTo option on a CSS file.

  1. Even though rebaseRelativeTo was set as an option, it wasn't being used. It was always being overwritten by a path based on the relativeTo option. Changed logic to use options value if it is defined.
  2. The regular expression used to find/replace instances of url() with the new url based on the rebaseRelativeTo only allowed one url() per line and the url had to end with a semi-colon. But it is valid for a font-face url() to appear multiple times on the same line and not end with a semi-colon. See this article. In order to make this work I changed the regular expression to ignore the semi-colon, not do a global search, and set each subsequent search to start from the previous index+1.

All tests pass.

@jrit
Copy link
Owner

jrit commented Mar 2, 2017

Awesome, thank you! Is there any way you can update or add test cases to prevent any future regressions related to your fixes?

@seyfert
Copy link
Contributor Author

seyfert commented Mar 2, 2017

Sure. I'll try to add tests for rebaseRelativeTo in the next few days.

@seyfert
Copy link
Contributor Author

seyfert commented Mar 5, 2017

I found another issue while testing. The util function getInlineFilePath did not support fragment URLs. I fixed that and added two additional tests that cover all the changes.

@jrit
Copy link
Owner

jrit commented Mar 6, 2017

This looks great, thank you. I'll work on publishing a release today.

@jrit jrit merged commit e6b4dd7 into jrit:master Mar 6, 2017
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

Successfully merging this pull request may close these issues.

2 participants