Commit Graph

52 Commits

Author SHA1 Message Date
Joey Parrish
d53c651921 fix: detection of absolute URLs
If a URL is resolved before checking for absolute URLs, even relative
URLs will be detected as absolute.

Includes updates to the skip-absolute-urls test.

Closes #126
2016-11-17 11:20:13 -08:00
Joey Parrish
68c345ae8e feat: inline favicons with rel="shortcut icon"
If the page is using rel="shortcut icon" instead of rel="icon", the
author will be surprised that the icon was not inlined, and may not
notice.  It would be better to inline that icon.

Includes updates to the favicon tests.

Related to issue #126
2016-11-17 11:19:59 -08:00
Remy Sharp
109555f690 fix: don't encode by default
Fixes #109
2016-08-09 22:05:33 +01:00
Remy Sharp
c085114ebf fix: ensure svg viewBox is kept
Fixes #102

Use lowerCaseAttributeNames=false when SVG present
2016-07-31 15:38:27 +01:00
Remy Sharp
0772d51069 fix: don't bail on corrupted URLs
Fixes #104

It will warn about them, but not fail the job, instead replacing the URL with '' (which is just as bad as the corrupted url, but at least it finishes).
2016-07-31 15:38:27 +01:00
Remy Sharp
0ae1301641 fix: don't remove SSI
Fixes #110
2016-07-31 15:38:26 +01:00
Cade Scroggins
701bf13678 fix: don't inline background images when the images option is false
also includes tests
2016-07-31 15:38:26 +01:00
Mikael Finstad
a2869fc81a fix: non-ascii characters
When doing a request with the node request module with an URL
containing UTF-8 chars, some webservers will fail to find the file.
Therefore encodeURI on the url before requesting it.
Not sure if this is the best way to test it, but it works with all test cases.

Example of page which doesn't inline properly:
http://hotpoticeland.com/holsgerdislaug/
which links to the image:
http://hotpoticeland.com/wp-content/uploads/Hólsgerðislaug-300x225.jpg
2016-07-31 15:38:26 +01:00
Remy Sharp
ae44accdd0 tests: update for new parsing 2016-05-22 22:27:10 +01:00
Remy Sharp
734dafb136 fix: headers use colons
The headers option was supposed to mirror cURL, but they were wrongly splitting on `=` and not `:`. This fix updates.
2016-05-22 22:25:50 +01:00
Remy Sharp
253a3173cd fix: wrap all CSS data urls in quotes
This ensures that if SVG is used as a background, it doesn't get corrupted.

Fixes #97
Fixes #96
2016-05-22 14:45:52 +01:00
Shin'ya Ueoka
925c99e2c3 fix: detect xml-mode with XML declaration 2016-05-17 22:36:54 +09:00
Remy Sharp
0ddff8886f fix: local content should use fs for inlining
The issue here was that although the "simple" detection was in place if the URL looked like HTML (i.e. has an angle bracket in it), but it didn't ever set the `isFile` flag.

This fix corrects this, but also swallows ENOENT errors, to mirror >=400 response codes being swallowed (i.e. return an empty body).

Fixes #89
2016-04-20 21:42:48 +01:00
Remy Sharp
731e7e9351 chore: merge branch 'feature/local-only'
* 'feature/local-only' of https://github.com/eigenuser/inliner:
  chore: renamed flag to --skip-absolute-urls
  chore: renamed flag to --same-origin-only
  feat: support for only inlining local files
2016-04-19 11:19:50 +01:00
Eugene Park
825ec601dc chore: renamed flag to --skip-absolute-urls 2016-04-06 08:02:46 +00:00
Remy Sharp
c0a632b24b test: improve coverage 2016-02-28 09:51:10 +00:00
Remy Sharp
51f0ca07ba fix: support favicons
Fixes #87
2016-02-28 09:50:05 +00:00
Eugene Park
15e6b0dab6 chore: renamed flag to --same-origin-only 2016-02-20 23:59:30 +00:00
Eugene Park
353a2a92cb feat: support for only inlining local files 2016-02-20 10:45:46 +00:00
Remy Sharp
7c33ee7d23 chore: merge branch 'feature/headers' 2016-01-18 22:15:34 +00:00
Remy Sharp
4ed1b39529 feat: support custom headers
Via cli using `-H user-agent="inliner custom"`

Fixes #69
Closes #59
2016-01-18 22:12:52 +00:00
Remy Sharp
0ea78f662d test: check for meta http-equiv 2016-01-18 21:04:31 +00:00
Remy Sharp
c6073e9e0a test: add meta-data stripping test 2016-01-18 20:54:44 +00:00
Stu Cox
6c9bba2adb feat: add support for inlining assets in style attributes
Fixes #65
2016-01-18 11:49:48 +00:00
Remy Sharp
5d7c439d92 test: don't touch non-script scripts 2015-11-26 19:49:31 +00:00
Ricardo Pescuma Domenecci
e32fc0abc7 test: added tests for inlinemin and nocompress js 2015-11-26 10:29:27 +00:00
dotob
82fb14c11f fix: strip img query string from local files
When ? was left in url and parsing a local file.

Fixes #72
2015-11-26 10:28:43 +00:00
Remy Sharp
6e46680fbd feat: support plain HTML as a source
Supports both HTML being passed as the first argument to the inliner function (through various detection), but also on the CLI supports HTML being piped, via `cat foo | inliner`.

Fixes #66
Closes #73
2015-11-26 10:24:12 +00:00
Felix Akkermans
cbcd398182 fix: resolving already resolved HTTP links in file
Also includes tests
2015-11-26 10:24:12 +00:00
Hubert SABLONNIÈRE
747836d3e0 feat: inline video (and their poster image attribute)
Video (and their poster) inlining is disabled by default.
It sounds crazy but for videos with a "reasonable length", it works just fine.
2015-09-22 00:59:22 +02:00
Sam Nguyen
8af810faa7 fix: replace with empty string if error in GET
Fixes #61

It seems to work, but I'm not sure if it's a clean way of doing it. Let
me know what you think @remy.
2015-08-28 20:20:52 -07:00
Remy Sharp
9904b6b334 feat: compress SVG using SVGO
Fixes #58

Compresses inline SVG using SVGO, and compresses CSS background SVG images by making them data URLs (using text/svg+xml mime).

Adds CLI (and lib) option: --nosvg which avoids using SVGO for compression (as it can on occassion mess up).

Also includes a refactor of the code to organise the files a little better (allowing for further inlined elements to be added).
2015-08-26 22:43:40 +01:00
Remy Sharp
bf1860271f feat: detect encoding
Using charset and jschardet allows us to detect the encoding, whilst still supporting allowing the user to override.

Technique via: http://stackoverflow.com/questions/12326688/node-js-scrape-encoding/18712021#18712021

Fixes #60
2015-08-23 22:43:14 +01:00
Manolis Stamatogiannakis
cf68995f03 test: add tests for specifying encoding 2015-08-23 22:43:02 +01:00
Remy Sharp
c439d79f5a fix: handles already inlined content
Fixes #26

Inliner was trying to resolve and request `data:` urls. Now it checks to see if it's already inlined.

I also updated the whole `.get` method to make smarter use of the caching. Originally the cache is only populated when the request has completed, but if the same image is on the page 20 times, the request would be made 20 times. Now, we cache the promise, so the request is only placed once, and returns a re-usable promise if it's already in progress or resolved.
2015-07-30 23:55:00 +01:00
Remy Sharp
54aae10c43 chore: merge master
Merge branch 'collapse-whitespace' of https://github.com/hsablonniere/inliner into hsablonniere-collapse-whitespace
2015-07-29 15:36:30 +01:00
Hubert SABLONNIÈRE
fae14c92c3 fix: keep whitespaces and newlines in pre and textareas 2015-07-29 15:03:15 +02:00
Hubert SABLONNIÈRE
32dfd8ce02 fix: encode binaries properly when requested via HTTP
The options parameter { encoding: 'binary' } set in image.js was lost.
It was not used in the main get() function and was not passed the function in get.js.
2015-07-29 14:30:36 +02:00
Hubert SABLONNIÈRE
e20c0bd7bd fix: inline scripts containing ETAGO properly
The fix is done by escaping all "</script" to "<\/script" according to Mathias Bynens article :
https://mathiasbynens.be/notes/etago
2015-07-29 03:05:06 +02:00
Hubert SABLONNIÈRE
214f698f95 fix: prevent signs like "<" or ">" to be treated as HTML in styles 2015-07-28 17:47:45 +02:00
Hubert SABLONNIÈRE
4e7acd39bb fix: prevent signs like "<" or ">" to be treated as HTML in scripts 2015-07-28 17:36:00 +02:00
Remy Sharp
593a2749cf fix: file based scripts
Parser was getting a buffer, so it needed to be coersed to a string.

Fixes #52
2015-07-28 14:49:10 +01:00
Remy Sharp
0590ce4a3b chore: merge master 2015-07-28 14:43:40 +01:00
Guillaume Girou
f89ed538f5 test: local js script not minified
Fail to uglify local js script with TypeError: undefined is not a function
2015-07-28 15:24:17 +02:00
Remy Sharp
aace364794 test: put jscs as part of tests
Because, yes, I'd like a consistent code style!
2015-07-28 13:40:09 +01:00
Remy Sharp
c8e4cab6ca test: simplify assets in tests 2015-07-28 10:48:29 +01:00
Remy Sharp
348f8a3199 test: include external import test
And contributing file for others to see how to file issues
2015-07-28 10:21:18 +01:00
Remy Sharp
06c8132aa3 fix: minified scripts being removed
Also add test
2015-07-28 07:12:46 +01:00
Remy Sharp
6653796461 test: add full tests 2015-07-27 22:13:21 +01:00
Remy Sharp
743018c1a0 feat: scripts and compression 2015-07-27 16:00:56 +01:00