Skip to content

Commit 698f036

Browse files
authored
[fix] Ignore urls starting with # (#106)
1 parent f33d4f9 commit 698f036

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/pigment-css-unplugin/src/utils.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ export const handleUrlReplacement = async (
2929
if (
3030
mainItem.startsWith('data:') ||
3131
mainItem.startsWith('http:') ||
32-
mainItem.startsWith('https:')
32+
mainItem.startsWith('https:') ||
33+
mainItem.startsWith('#')
3334
) {
3435
newCss += `url(${mainItem})`;
3536
} else if (mainItem[0] === '/') {

packages/pigment-css-unplugin/tests/utils.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ const dummyResolver = (url: string) => {
1111

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

0 commit comments

Comments
 (0)