Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2022-09-27 04:48:55 +0300
committerJuan José Arboleda <soyjuanarbol@gmail.com>2022-10-11 22:45:28 +0300
commit3cb28bdde098c565743ebee0f10af4a2b2bf7741 (patch)
tree0c5259ac1b43223175462b5ae8074a68c9c47977 /lib
parentb06a78e85dfae453030f8e6a741ac70922a32c9a (diff)
path: change basename() argument from ext to suffix
Closes: https://github.com/nodejs/node/issues/44773 PR-URL: https://github.com/nodejs/node/pull/44774 Fixes: https://github.com/nodejs/node/issues/44773 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/path.js32
1 files changed, 16 insertions, 16 deletions
diff --git a/lib/path.js b/lib/path.js
index fd95361dd02..e662e50d6c6 100644
--- a/lib/path.js
+++ b/lib/path.js
@@ -743,12 +743,12 @@ const win32 = {
/**
* @param {string} path
- * @param {string} [ext]
+ * @param {string} [suffix]
* @returns {string}
*/
- basename(path, ext) {
- if (ext !== undefined)
- validateString(ext, 'ext');
+ basename(path, suffix) {
+ if (suffix !== undefined)
+ validateString(suffix, 'ext');
validateString(path, 'path');
let start = 0;
let end = -1;
@@ -763,10 +763,10 @@ const win32 = {
start = 2;
}
- if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
- if (ext === path)
+ if (suffix !== undefined && suffix.length > 0 && suffix.length <= path.length) {
+ if (suffix === path)
return '';
- let extIdx = ext.length - 1;
+ let extIdx = suffix.length - 1;
let firstNonSlashEnd = -1;
for (let i = path.length - 1; i >= start; --i) {
const code = StringPrototypeCharCodeAt(path, i);
@@ -786,7 +786,7 @@ const win32 = {
}
if (extIdx >= 0) {
// Try to match the explicit extension
- if (code === StringPrototypeCharCodeAt(ext, extIdx)) {
+ if (code === StringPrototypeCharCodeAt(suffix, extIdx)) {
if (--extIdx === -1) {
// We matched the extension, so mark this as the end of our path
// component
@@ -1300,22 +1300,22 @@ const posix = {
/**
* @param {string} path
- * @param {string} [ext]
+ * @param {string} [suffix]
* @returns {string}
*/
- basename(path, ext) {
- if (ext !== undefined)
- validateString(ext, 'ext');
+ basename(path, suffix) {
+ if (suffix !== undefined)
+ validateString(suffix, 'ext');
validateString(path, 'path');
let start = 0;
let end = -1;
let matchedSlash = true;
- if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
- if (ext === path)
+ if (suffix !== undefined && suffix.length > 0 && suffix.length <= path.length) {
+ if (suffix === path)
return '';
- let extIdx = ext.length - 1;
+ let extIdx = suffix.length - 1;
let firstNonSlashEnd = -1;
for (let i = path.length - 1; i >= 0; --i) {
const code = StringPrototypeCharCodeAt(path, i);
@@ -1335,7 +1335,7 @@ const posix = {
}
if (extIdx >= 0) {
// Try to match the explicit extension
- if (code === StringPrototypeCharCodeAt(ext, extIdx)) {
+ if (code === StringPrototypeCharCodeAt(suffix, extIdx)) {
if (--extIdx === -1) {
// We matched the extension, so mark this as the end of our path
// component