svg-sprite: bug: 2.0.0: `shape.id.separator` does not produce an `id` with the parent directory names

In 1.5.0 shape.id.separator traversed full directory path + file name into the shape ID. Now in 2.0.0 shape ID is always a svg file name, without any parent folders.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 4
  • Comments: 21 (14 by maintainers)

Most upvoted comments

Released in v2.0.1

Hi, the problem is related with the change in shape.js line 150:

In version 1.5.4 it was: https://github.com/svg-sprite/svg-sprite/blob/v1.5.4/lib/svg-sprite/shape.js#L150

(It was getting the difference between the full path to the file and the path used to search files).

And now in version 2.0:

[It’s getting th](https://github.com/svg-sprite/svg-sprite/blob/v2.0.0/lib/svg-sprite/shape.js#L151)

It’s getting the name of the full path:

image

image

Before:

image

And the code in the createIdGenerator (not changed), at line 41, it’s waiting a relative path (it’s also explined in the variable comment). https://github.com/svg-sprite/svg-sprite/blob/v1.5.4/lib/svg-sprite/shape.js#L33 https://github.com/svg-sprite/svg-sprite/blob/v2.0.0/lib/svg-sprite/shape.js#L33

So, it can restore the previous line, or comparing the directory full path with the directory base path used to search with path.relative:

image

And the ID generated is going to have the expected value:

image

I just wanted to add that this didn’t work for me if the glob-pattern does not contain the “./” in the beginning.

Does not work:

path/to/somefolder/**/*.svg

Does work:

path/to/somefolder/./**/*.svg

I think I might know what’s the root cause. I’ll try to have a closer look later.

On Tue, Nov 8, 2022, 15:43 Yehor Kolesnykov @.***> wrote:

In my case here https://github.com/svg-sprite/svg-sprite/blob/main/lib/svg-sprite.js#L83

file is /home/egor/projects/yourapp-uikit-web/libs/ui-kit/src/lib/icons/svg-icons/eva/line/info.svg

name is eva/line/info.svg

— Reply to this email directly, view it on GitHub https://github.com/svg-sprite/svg-sprite/issues/740#issuecomment-1307243006, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACVLNMDEUB2NWA2X45QDY3WHJKHVANCNFSM6AAAAAAREKZ7GM . You are receiving this because you modified the open/close state.Message ID: @.***>