Skip to content

Commit 46e0245

Browse files
committed
AG-48918 fix __dirname resolution using fileURLToPath for cross-platform compatibility
Squashed commit of the following: commit 750bfb5 Author: slvvko <v.leleka@adguard.com> Date: Fri Nov 28 10:14:45 2025 -0500 bump patch version commit b570be3 Author: slvvko <v.leleka@adguard.com> Date: Fri Nov 28 10:09:08 2025 -0500 fix __dirname resolution using fileURLToPath for cross-platform compatibility
1 parent d7d2640 commit 46e0245

File tree

6 files changed

+17
-5
lines changed

6 files changed

+17
-5
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [v3.2.2] - 2025-11-28
9+
10+
### Fixed
11+
12+
- Build on Windows due to incorrect path handling.
13+
14+
[v3.2.2]: https://github.com/AdguardTeam/FiltersCompiler/compare/v3.2.1...v3.2.2
15+
816
## [v3.2.1] - 2025-11-27
917

1018
### Fixed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@adguard/filters-compiler",
3-
"version": "3.2.1",
3+
"version": "3.2.2",
44
"description": "AdGuard filters compiler",
55
"homepage": "http://adguard.com",
66
"type": "module",

src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import path from 'path';
2+
import { fileURLToPath } from 'url';
23
import { setConfiguration, CompatibilityTypes } from '@adguard/tsurlfilter';
34

45
import { build } from './main/builder';
@@ -12,7 +13,7 @@ import { platformsConfig } from './main/platforms-config';
1213
// Sets configuration compatibility
1314
setConfiguration({ compatibility: CompatibilityTypes.Corelibs });
1415

15-
const __dirname = path.dirname(new URL(import.meta.url).pathname);
16+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
1617

1718
const jsonSchemasConfigDir = path.join(__dirname, './schemas/');
1819

src/main/builder.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import fs from 'fs';
44
import path from 'path';
5+
import { fileURLToPath } from 'url';
56
import md5 from 'md5';
67

78
import { FiltersDownloader } from '@adguard/filters-downloader';
@@ -17,7 +18,7 @@ import { downloadFile } from './utils/webutils';
1718
import { getFilterIdFromDirName } from './utils/utils';
1819
import { optimizeDomainBlockingRules } from './utils/builder-utils';
1920

20-
const __dirname = path.dirname(new URL(import.meta.url).pathname);
21+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
2122

2223
const TEMPLATE_FILE = 'template.txt';
2324
const FILTER_FILE = 'filter.txt';

src/main/locales-validator.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
/* eslint-disable global-require */
22
import fs from 'fs';
33
import path from 'path';
4+
import { fileURLToPath } from 'url';
45
import { logger } from './utils/log';
56

6-
const __dirname = path.dirname(new URL(import.meta.url).pathname);
7+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
78

89
/**
910
* Each filter, group, tag should have two keys.

src/main/platforms/generator.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint-disable global-require */
22
import fs from 'fs';
33
import path from 'path';
4+
import { fileURLToPath } from 'url';
45
import crypto from 'crypto';
56
import moment from 'moment';
67

@@ -19,7 +20,7 @@ import { convertToUbo } from '../converter';
1920
import { getFilterOptimizationConfig } from '../optimization';
2021
import { RuleMasks } from '../rule/rule-masks';
2122

22-
const __dirname = path.dirname(new URL(import.meta.url).pathname);
23+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
2324

2425
const RULES_SEPARATOR = '\r\n';
2526
let filterIdsPool = [];

0 commit comments

Comments
 (0)