Skip to content

Commit

Permalink
[e] (0) it was pointed out that Unix paths can contain backslashes
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.whatwg.org/webapps@6229 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Jun 15, 2011
1 parent 0f6bb10 commit fa3a9d8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
10 changes: 5 additions & 5 deletions complete.html
Expand Up @@ -46305,16 +46305,16 @@ <h6 id=file-upload-state><span class=secno>4.10.7.1.18 </span><dfn title=attr-in
following function extracts the filename in a suitably compatible
manner:</p>

<pre>function extractFilename(path) {<!--
<pre>function extractFilename(path) {
if (path.substr(0, 12) == "C:\\fakepath\\")
return path.substr(12);-->
return path.substr(12); // modern browser
var x;
x = path.lastIndexOf('\\');
if (x &gt;= 0) // Windows-based path
return path.substr(x+1);
x = path.lastIndexOf('/');
if (x &gt;= 0) // Unix-based path
return path.substr(x+1);
x = path.lastIndexOf('\\');
if (x &gt;= 0) // Windows-based path
return path.substr(x+1);
return path; // just the filename
}</pre>

Expand Down
10 changes: 5 additions & 5 deletions index
Expand Up @@ -46298,16 +46298,16 @@ interface <dfn id=htmlformelement>HTMLFormElement</dfn> : <a href=#htmlelement>H
following function extracts the filename in a suitably compatible
manner:</p>

<pre>function extractFilename(path) {<!--
<pre>function extractFilename(path) {
if (path.substr(0, 12) == "C:\\fakepath\\")
return path.substr(12);-->
return path.substr(12); // modern browser
var x;
x = path.lastIndexOf('\\');
if (x &gt;= 0) // Windows-based path
return path.substr(x+1);
x = path.lastIndexOf('/');
if (x &gt;= 0) // Unix-based path
return path.substr(x+1);
x = path.lastIndexOf('\\');
if (x &gt;= 0) // Windows-based path
return path.substr(x+1);
return path; // just the filename
}</pre>

Expand Down
10 changes: 5 additions & 5 deletions source
Expand Up @@ -51920,16 +51920,16 @@ interface <dfn>HTMLFormElement</dfn> : <span>HTMLElement</span> {
following function extracts the filename in a suitably compatible
manner:</p>

<pre>function extractFilename(path) {<!--
<pre>function extractFilename(path) {
if (path.substr(0, 12) == "C:\\fakepath\\")
return path.substr(12);-->
return path.substr(12); // modern browser
var x;
x = path.lastIndexOf('\\');
if (x >= 0) // Windows-based path
return path.substr(x+1);
x = path.lastIndexOf('/');
if (x >= 0) // Unix-based path
return path.substr(x+1);
x = path.lastIndexOf('\\');
if (x >= 0) // Windows-based path
return path.substr(x+1);
return path; // just the filename
}</pre>

Expand Down

0 comments on commit fa3a9d8

Please sign in to comment.