| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b06a78e commit 3cb28bd
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -62,7 +62,7 @@ example, `path.resolve('C:\\')` can potentially return a different result than | |||
| 62 | 62 | `path.resolve('C:')`. For more information, see | |
| 63 | 63 | [this MSDN page][MSDN-Rel-Path]. | |
| 64 | 64 | ||
| 65 | - ## `path.basename(path[, ext])` | ||
| 65 | + ## `path.basename(path[, suffix])` | ||
| 66 | 66 | ||
| 67 | 67 | <!-- YAML | |
| 68 | 68 | added: v0.1.25 | |
@@ -73,12 +73,12 @@ changes: | |||
| 73 | 73 | --> | |
| 74 | 74 | ||
| 75 | 75 | * `path` {string} | |
| 76 | - * `ext` {string} An optional file extension | ||
| 76 | + * `suffix` {string} An optional suffix to remove | ||
| 77 | 77 | * Returns: {string} | |
| 78 | 78 | ||
| 79 | 79 | The `path.basename()` method returns the last portion of a `path`, similar to | |
| 80 | - the Unix `basename` command. Trailing directory separators are ignored, see | ||
| 81 | - [`path.sep`][]. | ||
| 80 | + the Unix `basename` command. Trailing [directory separators][`path.sep`] are | ||
| 81 | + ignored. | ||
| 82 | 82 | ||
| 83 | 83 | ```js | |
| 84 | 84 | path.basename('/foo/bar/baz/asdf/quux.html'); | |
@@ -101,7 +101,7 @@ path.win32.basename('C:\\foo.HTML', '.html'); | |||
| 101 | 101 | // Returns: 'foo.HTML' | |
| 102 | 102 | ``` | |
| 103 | 103 | ||
| 104 | - A [`TypeError`][] is thrown if `path` is not a string or if `ext` is given | ||
| 104 | + A [`TypeError`][] is thrown if `path` is not a string or if `suffix` is given | ||
| 105 | 105 | and is not a string. | |
| 106 | 106 | ||
| 107 | 107 | ## `path.delimiter` | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -743,12 +743,12 @@ const win32 = { | |||
| 743 | 743 | ||
| 744 | 744 | /** | |
| 745 | 745 | * @param {string} path | |
| 746 | - * @param {string} [ext] | ||
| 746 | + * @param {string} [suffix] | ||
| 747 | 747 | * @returns {string} | |
| 748 | 748 | */ | |
| 749 | - basename(path, ext) { | ||
| 750 | - if (ext !== undefined) | ||
| 751 | - validateString(ext, 'ext'); | ||
| 749 | + basename(path, suffix) { | ||
| 750 | + if (suffix !== undefined) | ||
| 751 | + validateString(suffix, 'ext'); | ||
| 752 | 752 | validateString(path, 'path'); | |
| 753 | 753 | let start = 0; | |
| 754 | 754 | let end = -1; | |
@@ -763,10 +763,10 @@ const win32 = { | |||
| 763 | 763 | start = 2; | |
| 764 | 764 | } | |
| 765 | 765 | ||
| 766 | - if (ext !== undefined && ext.length > 0 && ext.length <= path.length) { | ||
| 767 | - if (ext === path) | ||
| 766 | + if (suffix !== undefined && suffix.length > 0 && suffix.length <= path.length) { | ||
| 767 | + if (suffix === path) | ||
| 768 | 768 | return ''; | |
| 769 | - let extIdx = ext.length - 1; | ||
| 769 | + let extIdx = suffix.length - 1; | ||
| 770 | 770 | let firstNonSlashEnd = -1; | |
| 771 | 771 | for (let i = path.length - 1; i >= start; --i) { | |
| 772 | 772 | const code = StringPrototypeCharCodeAt(path, i); | |
@@ -786,7 +786,7 @@ const win32 = { | |||
| 786 | 786 | } | |
| 787 | 787 | if (extIdx >= 0) { | |
| 788 | 788 | // Try to match the explicit extension | |
| 789 | - if (code === StringPrototypeCharCodeAt(ext, extIdx)) { | ||
| 789 | + if (code === StringPrototypeCharCodeAt(suffix, extIdx)) { | ||
| 790 | 790 | if (--extIdx === -1) { | |
| 791 | 791 | // We matched the extension, so mark this as the end of our path | |
| 792 | 792 | // component | |
@@ -1300,22 +1300,22 @@ const posix = { | |||
| 1300 | 1300 | ||
| 1301 | 1301 | /** | |
| 1302 | 1302 | * @param {string} path | |
| 1303 | - * @param {string} [ext] | ||
| 1303 | + * @param {string} [suffix] | ||
| 1304 | 1304 | * @returns {string} | |
| 1305 | 1305 | */ | |
| 1306 | - basename(path, ext) { | ||
| 1307 | - if (ext !== undefined) | ||
| 1308 | - validateString(ext, 'ext'); | ||
| 1306 | + basename(path, suffix) { | ||
| 1307 | + if (suffix !== undefined) | ||
| 1308 | + validateString(suffix, 'ext'); | ||
| 1309 | 1309 | validateString(path, 'path'); | |
| 1310 | 1310 | ||
| 1311 | 1311 | let start = 0; | |
| 1312 | 1312 | let end = -1; | |
| 1313 | 1313 | let matchedSlash = true; | |
| 1314 | 1314 | ||
| 1315 | - if (ext !== undefined && ext.length > 0 && ext.length <= path.length) { | ||
| 1316 | - if (ext === path) | ||
| 1315 | + if (suffix !== undefined && suffix.length > 0 && suffix.length <= path.length) { | ||
| 1316 | + if (suffix === path) | ||
| 1317 | 1317 | return ''; | |
| 1318 | - let extIdx = ext.length - 1; | ||
| 1318 | + let extIdx = suffix.length - 1; | ||
| 1319 | 1319 | let firstNonSlashEnd = -1; | |
| 1320 | 1320 | for (let i = path.length - 1; i >= 0; --i) { | |
| 1321 | 1321 | const code = StringPrototypeCharCodeAt(path, i); | |
@@ -1335,7 +1335,7 @@ const posix = { | |||
| 1335 | 1335 | } | |
| 1336 | 1336 | if (extIdx >= 0) { | |
| 1337 | 1337 | // Try to match the explicit extension | |
| 1338 | - if (code === StringPrototypeCharCodeAt(ext, extIdx)) { | ||
| 1338 | + if (code === StringPrototypeCharCodeAt(suffix, extIdx)) { | ||
| 1339 | 1339 | if (--extIdx === -1) { | |
| 1340 | 1340 | // We matched the extension, so mark this as the end of our path | |
| 1341 | 1341 | // component | |
| Back | FazBrowse Home | New Git URL |
0 commit comments