Skip to content

Commit

Permalink
correctly strip www from filename - fixes #70
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Apr 3, 2014
1 parent 88a7840 commit f9613f8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,8 @@ function generateSizes(url, size, opts) {
url = url.replace(/^localhost/, 'http://$&');
url = urlMod.parse(url).protocol ? url : 'http://' + url;

// strip `www.`
url = url.replace(/^(?:https?:\/\/)?www\./, '');

// make it a valid filename
var filenameUrl = slugifyUrl(url);
var filenameUrl = slugifyUrl(url).replace(/^(?:https?:\/\/)?www\./, '');

var filename = filenameUrl + '-' + size + '.png';
var dim = size.split(/x/i);
Expand Down
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ it('should generate screenshots', function (cb) {

it('should remove special characters from the URL to create a valid filename', function (cb) {
var items =[{
url: 'http://microsoft.com/?query=pageres*|<>:"\\',
url: 'http://www.microsoft.com/?query=pageres*|<>:"\\',
sizes: '1024x768'
}];

Expand Down

0 comments on commit f9613f8

Please sign in to comment.