Skip to content

getFolderByServerRelativePath seems to have issues with # in foldernames #3250

@chr-sad

Description

@chr-sad

Major Version

4.x

Minor Version Number

4.12.0

Target environment

All

Additional environment details

I'm using NodeJS v22.14.0

Expected or Desired Behavior

When I use the IWeb getFolderByServerRelativePath API I want to be able to use folder names including special characters like % and #. Currently when the folder name contains # in pnp v 4.12.0 the request is not handled correctly and resolves in 404 not found error because of truncated URLs.

Observed Behavior

When I call the API with parentFolderServerRelativeUrl='/sites/xxx/UploadDocumentLibraryLarge/test/xxx/test # test':

      const test = await webRef.getFolderByServerRelativePath(parentFolderServerRelativeUrl);
      const testItem = await test.getItem();

The request in the network tab is truncated before the #

Image

Steps to Reproduce

Here is a snippet of the Sample-Code:

  try {
    if (parentFolderServerRelativeUrl) {
      const test = await webRef.getFolderByServerRelativePath(parentFolderServerRelativeUrl);
      const testItem = await test.getItem();
      if (testItem) {
        console.log('testItem', testItem);
      }
    }
  }
  catch (err) { ... }

When the folder has # as a special character, the test.getItem() method results in an error.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions