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

(feat)gatsby-remark-copy-linked-files: create hashLength option to specify the digest hash length #16669

Closed
wants to merge 2 commits into from
Closed

(feat)gatsby-remark-copy-linked-files: create hashLength option to specify the digest hash length #16669

wants to merge 2 commits into from

Conversation

kimbaudi
Copy link
Contributor

Description

This PR adds a new option called hashLength that would allow users to specify the length of contentDigest

{
  resolve: `gatsby-remark-copy-linked-files`,
  options: {
      hashLength: 9
  },
},

Related Issues

@kimbaudi kimbaudi requested a review from a team as a code owner August 15, 2019 22:36
@kimbaudi
Copy link
Contributor Author

kimbaudi commented Aug 15, 2019

I am new to Jest and unit testing. I am having trouble testing with actual fs-extra functionality (i.e. existsSync, copy, and ensureDir) instead of mocked ones. Currently, the unit tests expects undefined values:

expect(imageURL(markdownAST)).toEqual(`/undefined/undefined.gif`)

In order to test this new hashLength option, I would have to be able to test it using an actual file. Does anybody know if this is possible with Jest? I'll start looking into it, but I am unsure. Maybe this type of test requires end-to-end testing with Cypress instead of Jest? If anyone can point me in the right direction, that would be really helpful.

@sidharthachatterjee
Copy link
Contributor

sidharthachatterjee commented Aug 15, 2019

I would be wary of adding this because if I understand correctly, it strips off characters off the contentDigest from a Node.

If a user needs to set a specific length, they can set the Node's contentDigest appropriately.

And they can pass in a format without it too. This seems fairly niche and I'm not sure if adding another config option is worth the small benefit here.

Based on the above, I'd prefer to close this and not add this option. What do you think @kimbaudi?

@sidharthachatterjee
Copy link
Contributor

@pieh Thoughts?

@pieh
Copy link
Contributor

pieh commented Aug 16, 2019

Why do you need that option? I can't really think of situation when I would want/need to mess with contentDigest?

@kimbaudi
Copy link
Contributor Author

personally, its fine to close this. I really don't need it. I think I misread something about long filename due to hashing from #10048. I will close this.

@kimbaudi kimbaudi closed this Aug 16, 2019
@kimbaudi kimbaudi deleted the topics/gatsby-remark-copy-linked-files-hash-length branch August 16, 2019 01:14
@sidharthachatterjee
Copy link
Contributor

Thanks @kimbaudi 👍

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.

3 participants