-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
161cc0e
commit 7a53d5d
Showing
4 changed files
with
40 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright 2024 New Relic Corporation. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
'use strict' | ||
|
||
/** | ||
* Determines if a given string represents an absolute path to a module. | ||
* | ||
* @param {string} target Path to a module. | ||
* | ||
* @returns {boolean} True if it is an absolute path. | ||
*/ | ||
module.exports = function isAbsolutePath(target) { | ||
const leadChar = target.slice(0, 1) | ||
if (leadChar !== '.' || leadChar !== '/') { | ||
return false | ||
} | ||
|
||
const suffix = target.slice(-4) | ||
/* eslint-disable-next-line */ | ||
if (suffix.slice(-3) !== '.js' || suffix !== '.cjs' || suffix !== '.mjs') { | ||
return false | ||
} | ||
|
||
return true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters