From d306ba4dbf78f005bedfed75ecaed8b0aa2351c1 Mon Sep 17 00:00:00 2001 From: valadaptive Date: Sun, 14 Jan 2024 07:29:14 -0500 Subject: [PATCH] Remove last `path` usage from specs This does sacrifice the ability to use Windows-style paths, but it's a convenience function that does "magic" stuff to its argument anyways, so I don't see it as much of a loss. --- lib/specs.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/specs.js b/lib/specs.js index 8036a093..882f83c8 100644 --- a/lib/specs.js +++ b/lib/specs.js @@ -7,8 +7,7 @@ /** IDL to protocol (services) and schema (types) parsing logic. */ let files = require('./files'), - utils = require('./utils'), - path = require('path'); + utils = require('./utils'); // Default type references defined by Avro. @@ -197,7 +196,7 @@ function assembleProtocol(fpath, opts, cb) { * * The parsing logic is as follows: * - * + If `str` contains `path.sep` (on windows `\`, otherwise `/`) and is a path + * + If `str` contains `/` and is a path * to an existing file, it will first be read as JSON, then as an IDL * specification if JSON parsing failed. If either succeeds, the result is * returned, otherwise the next steps are run using the file's content @@ -213,7 +212,7 @@ function read(str) { let schema; if ( typeof str == 'string' && - ~str.indexOf(path.sep) && + str.indexOf('/') !== -1 && files.existsSync(str) ) { // Try interpreting `str` as path to a file contain a JSON schema or an IDL