Skip to content

Commit edaa955

Browse files
committed
feat!: url support
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
1 parent 86497f4 commit edaa955

File tree

98 files changed

+2435
-925
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+2435
-925
lines changed

.dictionary.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
abar
22
attw
33
barx
4+
cdir
45
cefc
6+
cindex
57
codecov
68
commitlintrc
79
dbar

.github/infrastructure.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ branches:
3232
- context: gitguardian
3333
- context: lint
3434
- context: spelling
35-
- context: test (22)
3635
- context: test (23)
3736
- context: typescript (5.6.3)
3837
- context: typescript (5.7.1-rc)

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,6 @@ jobs:
309309
matrix:
310310
node-version:
311311
- 23
312-
- 22
313312
env:
314313
COVERAGE_SUMMARY: ./coverage/coverage-summary.json
315314
NODE_VERSION: ${{ matrix.node-version }}

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Universal drop-in replacement for [`node:path`][node-path]
2525
This package is a universal drop-in replacement for Node.js' [`path`][node-path] module.
2626

2727
It enforces consistency between POSIX and Windows operating systems and also provides additional utilities for working
28-
with file paths and extensions.
28+
with file URLs, paths, and extensions.
2929

3030
## When should I use this?
3131

@@ -99,6 +99,7 @@ import {
9999
isAbsolute,
100100
isDeviceRoot,
101101
isSep,
102+
isURL,
102103
join,
103104
matchesGlob,
104105
normalize,
@@ -111,6 +112,7 @@ import {
111112
root,
112113
sep,
113114
toNamespacedPath,
115+
toPath,
114116
toPosix
115117
} from '@flex-development/pathe'
116118
```
@@ -134,6 +136,7 @@ This package exports the following identifiers:
134136
- [`isAbsolute`](./src/lib/is-absolute.mts)
135137
- [`isDeviceRoot`](./src/lib/is-device-root.mts)
136138
- [`isSep`](./src/lib/is-sep.mts)
139+
- [`isURL`](./src/lib/is-url.mts)
137140
- [`join`](./src/lib/join.mts)
138141
- [`matchesGlob`](./src/lib/matches-glob.mts)
139142
- [`normalize`](./src/lib/normalize.mts)
@@ -147,6 +150,7 @@ This package exports the following identifiers:
147150
- [`root`](./src/lib/root.mts)
148151
- [`sep`](./src/lib/sep.mts)
149152
- [`toNamespacedPath`](./src/lib/to-namespaced-path.mts)
153+
- [`toPath`](./src/lib/to-path.mts)
150154
- [`toPosix`](./src/lib/to-posix.mts)
151155
- [`win32`](./src/pathe.mts)
152156

__fixtures__/drive.mts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* @file Fixtures - DRIVE
3+
* @module fixtures/drive
4+
*/
5+
6+
import type { DriveLetter } from '@flex-development/pathe'
7+
8+
/**
9+
* Windows drive letter.
10+
*
11+
* @const {DriveLetter} DRIVE
12+
*/
13+
const DRIVE: DriveLetter = 'T:'
14+
15+
export default DRIVE

__fixtures__/env.mts

Lines changed: 0 additions & 20 deletions
This file was deleted.

__tests__/plugins/chai-path.mts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/**
2+
* @file Plugins - chaiPath
3+
* @module tests/plugins/chaiPath
4+
*/
5+
6+
import type Chai from 'chai'
7+
import path from 'node:path'
8+
9+
export default plugin
10+
11+
/**
12+
* Chai assertion plugin for the Node.js [path][node-path] API.
13+
*
14+
* [node-path]: https://nodejs.org/api/path.html
15+
*
16+
* @see {@linkcode Chai.ChaiStatic}
17+
* @see {@linkcode Chai.ChaiUtils}
18+
*
19+
* @param {ChaiStatic} chai
20+
* `chai` export
21+
* @param {Chai.ChaiUtils} utils
22+
* `chai` utilities
23+
* @return {undefined}
24+
*/
25+
function plugin(chai: Chai.ChaiStatic, utils: Chai.ChaiUtils): undefined {
26+
utils.addMethod(chai.Assertion.prototype, extname.name, extname)
27+
28+
return void 0
29+
30+
/**
31+
* Assert the return value of {@linkcode path.extname}.
32+
*
33+
* @this {Chai.Assertion}
34+
*
35+
* @param {unknown} expected
36+
* Expected file extension
37+
* @return {undefined}
38+
*/
39+
function extname(this: Chai.Assertion, expected: unknown): undefined {
40+
/**
41+
* Subject of assertion.
42+
*
43+
* @const {string} subject
44+
*/
45+
const subject: string = utils.flag(this, 'object')
46+
47+
/**
48+
* File extension.
49+
*
50+
* @const {string} ext
51+
*/
52+
const actual: string = path.extname(subject)
53+
54+
return void this.assert(
55+
actual === expected,
56+
'expected extname of #{this} to be #{exp} but got #{act}',
57+
'expected extname of #{this} to not be #{act}',
58+
expected,
59+
actual
60+
)
61+
}
62+
}

__tests__/setup/chai.mts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @file Test Setup - chai
3+
* @module tests/setup/chai
4+
* @see https://chaijs.com
5+
*/
6+
7+
import chaiPath from '#tests/plugins/chai-path'
8+
import chaiString from 'chai-string'
9+
import { chai } from 'vitest'
10+
11+
/**
12+
* initialize chai plugins.
13+
*
14+
* @see https://github.com/onechiporenko/chai-string
15+
*/
16+
chai.use(chaiPath)
17+
chai.use(chaiString)

__tests__/setup/env.mts

Lines changed: 0 additions & 15 deletions
This file was deleted.

__tests__/utils/cwd-windows.mts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* @file Test Utilities - cwdWindows
3+
* @module tests/utils/cwdWindows
4+
*/
5+
6+
import DRIVE from '#fixtures/drive'
7+
import { ok } from 'devlop'
8+
import { posix, win32 } from 'node:path'
9+
10+
/**
11+
* Get the path to the current working directory as a windows drive path.
12+
*
13+
* @return {string}
14+
* Absolute path to current working directory
15+
*/
16+
function cwdWindows(): string {
17+
ok(typeof process.env['PWD'] === 'string', 'expected `process.env.PWD`')
18+
return DRIVE + process.env['PWD'].replaceAll(posix.sep, win32.sep)
19+
}
20+
21+
export default cwdWindows

0 commit comments

Comments
 (0)