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

Made tests cross platform #83

Merged
merged 8 commits into from
Jun 30, 2016
Merged

Made tests cross platform #83

merged 8 commits into from
Jun 30, 2016

Conversation

marklagendijk
Copy link

No description provided.

var safeFileName = urlPath.replace(/\.\./g, '.');
safeFileName = path.normalize(safeFileName);
return safeFileName;
return urlPath.substring(1).replace(/\.\./g, '.');
Copy link
Member

Choose a reason for hiding this comment

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

why do we need substring here?

Copy link
Author

Choose a reason for hiding this comment

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

We use urlPath which is the absolute path on the website, e.g.: /some/path/something.html. We want a relative path as a result, that is why we use .substring(1) to cut off the starting /.

Copy link
Member

Choose a reason for hiding this comment

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

ok, got it, thanks

@s0ph1e
Copy link
Member

s0ph1e commented Jun 30, 2016

Thanks @marklagendijk

  • I like that now by-type and by-structure name generators both return relative path
  • I think all path-related tests should be rewritten with equalFileSystemPath in order to make them unified. Now some test in test/unit/file-name-generators/by-type-test.js use new assertion, others use eql. Seems only failing tests were updated

And need to add CI for windows. I'm going to do it in #84

@marklagendijk
Copy link
Author

I indeed only updated failing tests. Will take a look at the ones I missed.

// if it replaces them we receive 'some/path/../../../../etc/passwd'
// path.resolve('some/path/../../../../etc/passwd'); = '/etc/passwd' => which is not safe
var r = new Resource('http://example.com/some/path/.../.../.../.../etc/passwd');
bySiteStructureFilenameGenerator(r, options).should.equalFileSystemPath('some/path/.../.../.../.../etc/passwd');
Copy link
Member

Choose a reason for hiding this comment

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

@marklagendijk need to think how to handle this. Because not it replaces ... => .. which makes code unsafe
we can:

  • create directories with names ... (as in test)
  • or cut that pieces

what do you think about this?

@s0ph1e s0ph1e merged commit 916bde0 into master Jun 30, 2016
@s0ph1e s0ph1e deleted the cross-platform-tests branch June 30, 2016 15:41
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