Skip to content

feat: support custom url -> file path in Node File System Persister #496

@jeswr

Description

@jeswr

Description

Allow for a custom handlers to be provided to the Node File System Persister for converting urls to file paths.

The use case that we have for this is so that we can hash the URL rather than creating a long path from the URL (comunica/comunica#1363 (comment)) - as the paths we are generating are too long for Windows machines which often have a MAX_PATH of ~256 chars (comunica/comunica#1363 (comment)). This could be configurable as an additional persisterOption in the setupPolly function like so:

  return setupPolly({
    adapters: [ NodeHttpAdapter ],
    persister: FSPersister,
    persisterOptions: { fs: { recordingsDir, urlToPath: (url: string) => md5(url) }},
    recordFailedRequests: true,
    matchRequestsBy: {
      headers: {
        exclude: [ 'user-agent' ],
      },
    },
  });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions