166 Commits

Author SHA1 Message Date
Matthias Mullie
33048c5fab Make add chainable
Fixes #125
2017-01-26 09:12:38 +01:00
Matthias Mullie
be5a61820f Stricter checks for not importing absolute paths
Fixes #100
2017-01-26 09:12:17 +01:00
Matthias Mullie
cd15113398 Also simplify external links paths
For normal files, @import & url() syntax is unified
already (e.g. removing quotes around the path, where
not needed), but this was not done for external
paths.

This also simplifies the huge regex a little
2017-01-25 16:38:45 +01:00
Matthias Mullie
6340735c46 Fix incorrect color replacement for colors starting with #foo 2016-11-23 11:11:07 +01:00
Matthias Mullie
101a56354d Restore previous regex extraction method
New code seems to have caused a few other issues, and the reason
for having changed it doesn't apply anymore (fixed elsewhere
already), so might as well restore this one :)

Fixes #146
2016-11-11 21:29:29 +01:00
Matthias Mullie
91c16fe4c2 Fix regex-extraction memory inefficiency
Fixes #147
2016-11-10 17:52:55 +01:00
Matthias Mullie
288b7c007e Alternative regex matching
Fixes #146
2016-11-10 17:01:10 +01:00
Matthias Mullie
9bcf6e2d36 Fix ASI regex extraction
Fixes #143
2016-11-10 11:04:50 +01:00
Matthias Mullie
7dd8d25fdb Improve regex detection
Fixes issue #142
2016-11-10 10:09:50 +01:00
Matthias Mullie
e93dffc8fa Don't strip import statements before empty tags
Fixes issue #145
2016-11-09 22:15:24 +01:00
Matthias Mullie
1a6cb6b457 Move line-feed normalization, to only affect code files, not file imports
Fixes issue #139
2016-10-27 15:32:49 -07:00
Matthias Mullie
be217ebca1 Merge branch 'master' of https://github.com/smxsm/minify into smxsm-master 2016-10-27 15:30:54 -07:00
Stefan Moises
53d98cd557 replace CR linefeeds etc. when loading files
Replace "wrong" linefeeds, e.g. if a file was saved on MacOS with CR only
2016-10-16 10:40:12 +02:00
Matthias Mullie
de4bcf23b6 php-cs-fixer 2016-10-13 13:49:22 +02:00
Matthias Mullie
099f5ec75d Fix passing array as argument to add
There were some issues with the interplay between an array
being passed, and the method being overloaded. Individually,
both would work, but when they're combined, it would fail.
2016-10-13 13:45:01 +02:00
Matthias Mullie
089afe6cd8 Merge pull request #132 from eko3alpha/master
Feature: Add ability to pass an array as an argument
2016-10-13 13:32:14 +02:00
Matthias Mullie
5bd843c5a4 Regex can also be followed by .
Fixes #138
2016-10-13 13:27:31 +02:00
Matthias Mullie
325e9b9dc1 Fix 0px minification in calc()
Fixes issue #137
2016-09-20 14:58:02 +02:00
Matthias Mullie
f03da3f743 Don't shorten bools if they're object literal keys
Fixes issue #134
2016-09-14 13:27:15 +02:00
Matthias Mullie
9e0dfaf1b1 Only strip whitespace after other operations
Property notation, for example, alters the content. If we've stripped
whitespace first, the transformations in propertynotation may no
longer be correct.

Fixed issue #133
2016-09-14 13:22:15 +02:00
Matthias Mullie
97a8f64bab Improve whitespace stripping around certain operators
1: some were not stripped agressively enough. E.g.:
   return !0 -> return!0
2: some were stripped too aggressive. E.g.:
   func()
   {1+2}
   Should not be joined on 1 line, since func() could be a function
   call and {1+2} an unrelated piece of code

Fixes issue #130
2016-09-14 13:13:59 +02:00
Matthias Mullie
d63980b5cf Regular expressions can also be followed by }
Fixes issue #124
2016-09-14 11:51:12 +02:00
Matthias Mullie
ac88354d6d Simplify regex & add test case for issue 120 2016-09-14 10:41:50 +02:00
aalvarado
54bdf69431 Feature: Add ability to pass an array of css and js assets as an argument
add() will now accept an array of js/css files, useful when your list of assets live in a config file
Add unit tests
Simplify test harness
2016-08-12 12:44:25 -04:00
Alex Corvi
ddfb6fc534 extractRegex() pattern modified 2016-07-03 13:00:36 +00:00
Matthias Mullie
3253a81d07 Shorten colors some more if their color name is shorter
As suggested on issue #109
2016-06-09 21:35:54 +02:00
Matthias Mullie
1a152541b0 Shorten font weights
As suggested on issue #109
2016-06-09 21:34:19 +02:00
Matthias Mullie
dcdedb0389 Improve regex extraction
Fixes issue #115
2016-06-09 21:04:46 +02:00
Matthias Mullie
75eff20d29 Suppress is_file errors, which may be caused by open_basedir
Fixes issue #111
2016-06-09 17:53:59 +02:00
Matthias Mullie
10b843d564 Add tests for issue #107 2016-04-27 13:06:55 +02:00
Matthias Mullie
272e461134 Fix '0' being replaces by first string's value
Fixes #99
2016-03-01 09:00:27 +01:00
Matthias Mullie
3176239d15 PHPDoc cleanup 2016-02-17 15:39:47 +01:00
Matthias Mullie
dc60e15734 Detect circular reference by passing data around
Stuffing paths in statics could affect other instances of the
same class
2016-02-17 14:23:55 +01:00
Matthias Mullie
3518f595e5 Restore original Exception class
I admit, having just this 1 Exception class in the root of the
project was a bad idea...
But now I can't take it away without breaking backwards compatibility:
people could be catching errors of this class.
So all new Exception classes have to inherit from this old one (it's
not worth breaking BC over, imo)
Also renamed the new ones to be "Exceptions" (plural), to avoid
confusing that namespace with the original exception class name.
2016-02-17 11:43:01 +01:00
Matthias Mullie
a6ebb921cb Add argument type to phpdoc
Meanwhile also removed some superfluous braces
2016-02-17 10:35:53 +01:00
Matthias Mullie
c17eb048da Restore earlier method of safeguarding newlines after regex
This replacement was a bit unsafe as it could confuse devision /
for end-of-regex
2016-02-17 10:09:38 +01:00
Matthias Mullie
2053c04da5 Spaces after // 2016-02-17 09:59:34 +01:00
Matthias Mullie
b77673f350 php-cs-fixer fixes 2016-02-17 09:58:12 +01:00
Gino Pane
ea2512a67c Restore visibility of hidden property. 2016-02-15 23:05:13 +03:00
Gino Pane
4049b6eed3 Test and prevent file import loops.
Issue: https://github.com/matthiasmullie/minify/issues/96

Updates:
- Added css files for testing and a new test-case;
- created new exception types and grouped them into separated directory;
- reuse some parts of the code.
2016-02-15 22:56:01 +03:00
Gino Pane
353acbad32 Improve Minify::writeToFile check conditions.
Notes:
PHP's fwrite only returns false if you call this function with an invalid argument. If any other error occurs it will return the number of bytes that has been written. So we have to add another check.
2016-02-13 23:22:27 +03:00
Gino Pane
db9383b8aa Increase code coverage.
- Fix contents of "tests\css\sample\convert_relative_path\source\absolute.css" to test @import without url();
- Change index in array of matches (Minify.php:321) to correctly replace empty strings.
2016-02-09 17:12:30 +03:00
Gino Pane
ddfe262a62 Tests for filesystem operations.
- Split Minify::save() to easily testable methods;
- Add tests.
2016-02-09 15:53:15 +03:00
Gino Pane
a51f4eb6d9 Merge branch 'feature/fix-tests' 2016-02-09 01:37:26 +03:00
Gino Pane
424a43fc8b Fix regex for matching regexes. 2016-02-09 01:37:05 +03:00
Gino Pane
fcc27e7990 Update comment, fix typo. 2016-02-09 00:52:06 +03:00
Gino Pane
35a7553660 - Add shell script to convert symlinks;
- Fix JSTest data for cross-system compatibility;
- Update test-case for https://github.com/matthiasmullie/minify/issues/56 and perform fixes;
- Some code simplifications, remove some code duplicates;
- Ignore test samples for convenience of running tests;
- Update readme.
2016-02-09 00:23:23 +03:00
Matthias Mullie
ad8508130e Ignore GET-params when converting paths
Fixes #77
2016-01-20 10:23:55 +01:00
Matthias Mullie
f69a620195 Also explicitly check path length for imports 2016-01-12 10:14:42 -08:00
Matthias Mullie
140c714688 Don't strip } when stripping empty tags preceeded by 2 }s
Fixes #92
2016-01-10 18:10:11 -08:00