Merge "build: Commit package-lock.json"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 10 Jun 2019 21:40:46 +0000 (21:40 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 10 Jun 2019 21:40:46 +0000 (21:40 +0000)
resources/lib/foreign-resources.yaml
resources/lib/jquery.chosen/README.md
resources/src/mediawiki.Title/Title.js
tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js

index 9f34e77..d737cbe 100644 (file)
@@ -121,7 +121,28 @@ jquery:
   integrity: sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60=
   dest: jquery.js
 
-# TODO: jquery.chosen
+jquery.chosen:
+  type: multi-file
+  files:
+    LICENSE:
+      src: https://raw.githubusercontent.com/harvesthq/chosen/v1.8.2/LICENSE.md
+      integrity: sha384-hxUqOVbJZTd9clMlf9yV18PjyKQ2rUOCXLgFNYlV/blpyeCyiUCpmVjAmNP0yc8M
+    README.md:
+      src: https://raw.githubusercontent.com/harvesthq/chosen/v1.8.2/README.md
+      integrity: sha384-ps8fQiOF1anPibj6QMNii4OcAbZNcy+dkmdJUZzqBgmfjaPth9YDe0TRIk89lfID
+    # Following files taken from CDN because they're built, and don't exist in the repo
+    chosen-sprite.png:
+      src: https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.2/chosen-sprite.png
+      integrity: sha384-QL0lDMjIhfcd5uzKEIPehkhx7l0gHWxFo1taNsY2hdDuYdGAadNhiwKueQ91R8KW
+    chosen-sprite@2x.png:
+      src: https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.2/chosen-sprite%402x.png
+      integrity: sha384-MSDzP+ofFO+lRrCZQn3dztHS/GdR8Ai907bxrRZeuGSi87G8XffEKTxxM99GTvr1
+    chosen.css:
+      src: https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.2/chosen.css
+      integrity: sha384-VeNz/jFhcqEG5UB40sPZW8Bg8sdtbtXW1038aqBPAZy/z/6j1XsSQjRUJ7NEM3nE
+    chosen.jquery.js:
+      src: https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.2/chosen.jquery.js
+      integrity: sha384-EzfvMGW4mwDo/InJrmR/UvtxTUUYUA0cfybfS8aqPG1ItoAQYYYDImWl1gaBzMfQ
 
 jquery.client:
   type: tar
index 5b21256..a3aa89e 100644 (file)
@@ -45,4 +45,3 @@ We welcome all to participate in making Chosen the best software it can be. The
 - Design and CSS by [Matthew Lettini](http://matthewlettini.com/)
 - Repository maintained by [@pfiller](http://github.com/pfiller), [@kenearley](http://github.com/kenearley), [@stof](http://github.com/stof), [@koenpunt](http://github.com/koenpunt), and [@tjschuck](http://github.com/tjschuck).
 - Chosen includes [contributions by many fine folks](https://github.com/harvesthq/chosen/contributors).
-
index 900dab2..259febc 100644 (file)
@@ -507,7 +507,7 @@ Title.makeTitle = function ( namespace, title ) {
  * @return {mw.Title|null} A valid Title object or null if the input cannot be turned into a valid title
  */
 Title.newFromUserInput = function ( title, defaultNamespaceOrOptions, options ) {
-       var namespace, m, id, ext, parts,
+       var namespace, m, id, ext, lastDot,
                defaultNamespace;
 
        // defaultNamespace is optional; check whether options moves up
@@ -553,35 +553,27 @@ Title.newFromUserInput = function ( title, defaultNamespaceOrOptions, options )
                namespace === NS_MEDIA ||
                ( options.forUploading && ( namespace === NS_FILE ) )
        ) {
-
                title = sanitize( title, [ 'generalRule', 'fileRule' ] );
 
                // Operate on the file extension
                // Although it is possible having spaces between the name and the ".ext" this isn't nice for
                // operating systems hiding file extensions -> strip them later on
-               parts = title.split( '.' );
-
-               if ( parts.length > 1 ) {
-
-                       // Get the last part, which is supposed to be the file extension
-                       ext = parts.pop();
+               lastDot = title.lastIndexOf( '.' );
 
-                       // Remove whitespace of the name part (that W/O extension)
-                       title = parts.join( '.' ).trim();
-
-                       // Cut, if too long and append file extension
-                       title = trimFileNameToByteLength( title, ext );
+               // No or empty file extension
+               if ( lastDot === -1 || lastDot >= title.length - 1 ) {
+                       return null;
+               }
 
-               } else {
+               // Get the last part, which is supposed to be the file extension
+               ext = title.slice( lastDot + 1 );
 
-                       // Missing file extension
-                       title = parts.join( '.' ).trim();
+               // Remove whitespace of the name part (that without extension)
+               title = title.slice( 0, lastDot ).trim();
 
-                       // Name has no file extension and a fallback wasn't provided either
-                       return null;
-               }
+               // Cut, if too long and append file extension
+               title = trimFileNameToByteLength( title, ext );
        } else {
-
                title = sanitize( title, [ 'generalRule' ] );
 
                // Cut titles exceeding the TITLE_MAX_BYTES byte size limit
index fca1f7d..a3f3cc8 100644 (file)
                                        title: 'File:Foo.JPEG  ',
                                        expected: 'File:Foo.JPEG',
                                        description: 'Page in File-namespace with trailing whitespace'
+                               },
+                               {
+                                       title: 'File:Foo',
+                                       description: 'File name without file extension'
+                               },
+                               {
+                                       title: 'File:Foo.',
+                                       description: 'File name with empty file extension'
                                }
                        ];