@serenity-js/core
Advanced tools
Comparing version 3.13.1 to 3.13.2
@@ -6,2 +6,13 @@ # Change Log | ||
## [3.13.2](https://github.com/serenity-js/serenity-js/compare/v3.13.1...v3.13.2) (2023-11-14) | ||
### Bug Fixes | ||
* **cucumber:** resolve paths to "imports" as absolute file URLs ([fc9aefc](https://github.com/serenity-js/serenity-js/commit/fc9aefcdc2ec8e1dfe3ce38b03a1ff7fd7d3c6c6)), closes [#2060](https://github.com/serenity-js/serenity-js/issues/2060) | ||
## [3.13.1](https://github.com/serenity-js/serenity-js/compare/v3.13.0...v3.13.1) (2023-11-07) | ||
@@ -8,0 +19,0 @@ |
@@ -0,1 +1,2 @@ | ||
/// <reference types="node" /> | ||
import { TinyType } from 'tiny-types'; | ||
@@ -6,3 +7,3 @@ export declare class Path extends TinyType { | ||
static fromJSON(v: string): Path; | ||
static fromURI(uri: string): Path; | ||
static fromFileURL(fileUrl: URL): Path; | ||
static from(...segments: string[]): Path; | ||
@@ -19,3 +20,4 @@ static fromSanitisedString(value: string): Path; | ||
root(): Path; | ||
toFileURL(): URL; | ||
} | ||
//# sourceMappingURL=Path.d.ts.map |
@@ -37,10 +37,9 @@ "use strict"; | ||
} | ||
static fromURI(uri) { | ||
static fromFileURL(fileUrl) { | ||
// inspired by https://github.com/TooTallNate/file-uri-to-path | ||
if (typeof uri !== 'string' || | ||
uri.length <= 7 || | ||
uri.slice(0, 7) !== 'file://') { | ||
throw new TypeError(`A Path can be created only from URIs that start with 'file://'. Received: ${uri}`); | ||
if (fileUrl.protocol !== 'file:') { | ||
throw new TypeError(`A Path can be created only from URLs that start with 'file://'. Received: ${fileUrl}`); | ||
} | ||
const rest = decodeURI(uri.slice(7)); | ||
const url = fileUrl.toString(); | ||
const rest = decodeURI(url.slice(7)); | ||
const firstSlash = rest.indexOf('/'); | ||
@@ -68,4 +67,3 @@ let host = rest.slice(0, Math.max(0, firstSlash)); | ||
if (upath_1.sep === '\\') { | ||
throw new Error('that used?'); | ||
// path = path.replace(/\//g, '\\'); | ||
path = path.replaceAll('/', '\\'); | ||
} | ||
@@ -79,2 +77,5 @@ if (!(/^.+:/.test(path))) { | ||
static from(...segments) { | ||
if (segments.length === 1 && segments[0].startsWith('file://')) { | ||
return Path.fromFileURL(new URL(segments[0])); | ||
} | ||
return new Path(upath_1.default.joinSafe(...segments)); | ||
@@ -119,2 +120,5 @@ } | ||
} | ||
toFileURL() { | ||
return new URL(encodeURI(`file://${this.value}`).replaceAll(/[#?]/g, encodeURIComponent)); | ||
} | ||
} | ||
@@ -121,0 +125,0 @@ exports.Path = Path; |
{ | ||
"name": "@serenity-js/core", | ||
"version": "3.13.1", | ||
"version": "3.13.2", | ||
"description": "Serenity/JS Screenplay, reporting engine and core interfaces.", | ||
@@ -74,3 +74,3 @@ "author": { | ||
}, | ||
"gitHead": "8f7c1b07dd23b1e1e6c8de49a4ec512a35b8a7f7" | ||
"gitHead": "ed08db56c2c947c2c2ac4d9d4e95f9f68e90d2a4" | ||
} |
@@ -13,15 +13,12 @@ import filenamify from 'filenamify'; | ||
static fromURI(uri: string): Path { | ||
static fromFileURL(fileUrl: URL): Path { | ||
// inspired by https://github.com/TooTallNate/file-uri-to-path | ||
if ( | ||
typeof uri !== 'string' || | ||
uri.length <= 7 || | ||
uri.slice(0, 7) !== 'file://' | ||
) { | ||
if (fileUrl.protocol !== 'file:') { | ||
throw new TypeError( | ||
`A Path can be created only from URIs that start with 'file://'. Received: ${ uri }` | ||
`A Path can be created only from URLs that start with 'file://'. Received: ${ fileUrl }` | ||
); | ||
} | ||
const rest = decodeURI(uri.slice(7)); | ||
const url = fileUrl.toString(); | ||
const rest = decodeURI(url.slice(7)); | ||
const firstSlash = rest.indexOf('/'); | ||
@@ -55,4 +52,3 @@ | ||
if (sep === '\\') { | ||
throw new Error('that used?') | ||
// path = path.replace(/\//g, '\\'); | ||
path = path.replaceAll('/', '\\'); | ||
} | ||
@@ -69,2 +65,5 @@ | ||
static from(...segments: string[]): Path { | ||
if (segments.length === 1 && segments[0].startsWith('file://')) { | ||
return Path.fromFileURL(new URL(segments[0])); | ||
} | ||
return new Path(path.joinSafe(...segments)); | ||
@@ -128,2 +127,8 @@ } | ||
} | ||
} | ||
toFileURL(): URL { | ||
return new URL( | ||
encodeURI(`file://${this.value}`).replaceAll(/[#?]/g, encodeURIComponent) | ||
); | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1366278
26993