Skip to content

Commit

Permalink
[fix] Ignore urls starting with # (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
brijeshb42 authored May 28, 2024
1 parent f33d4f9 commit 698f036
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/pigment-css-unplugin/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export const handleUrlReplacement = async (
if (
mainItem.startsWith('data:') ||
mainItem.startsWith('http:') ||
mainItem.startsWith('https:')
mainItem.startsWith('https:') ||
mainItem.startsWith('#')
) {
newCss += `url(${mainItem})`;
} else if (mainItem[0] === '/') {
Expand Down
4 changes: 2 additions & 2 deletions packages/pigment-css-unplugin/tests/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const dummyResolver = (url: string) => {

describe('utils', () => {
describe('handleUrlReplacement', () => {
it('should not replace http/data/absolute urls', async () => {
[DATA_URI, HTML_LOGO_URL, ABSOLUTE_PATH].forEach(async (url) => {
it('should not replace http/data/absolute/hash urls', async () => {
[DATA_URI, HTML_LOGO_URL, ABSOLUTE_PATH, '#my_gradient'].forEach(async (url) => {
const cssString1 = `.className {
background-image: url(${url});
}`;
Expand Down

0 comments on commit 698f036

Please sign in to comment.