[Groonga-commit] ranguba/chupa-text at 2b46824 [master] Improve extension detection for HTTP directory access

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Jul 12 00:15:10 JST 2017


Kouhei Sutou	2017-07-12 00:15:10 +0900 (Wed, 12 Jul 2017)

  New Revision: 2b46824418abb0f00f9d7cdcd964df6d1c316d87
  https://github.com/ranguba/chupa-text/commit/2b46824418abb0f00f9d7cdcd964df6d1c316d87

  Message:
    Improve extension detection for HTTP directory access

  Modified files:
    lib/chupa-text/data.rb
    lib/chupa-text/input-data.rb

  Modified: lib/chupa-text/data.rb (+5 -1)
===================================================================
--- lib/chupa-text/data.rb    2017-07-11 17:26:32 +0900 (64b491a)
+++ lib/chupa-text/data.rb    2017-07-12 00:15:10 +0900 (8f561af)
@@ -166,7 +166,11 @@ module ChupaText
     #   lower case like `pdf` not `PDF`.
     def extension
       return nil if****@uri*****?
-      File.extname(@uri.path).downcase.gsub(/\A\./, "")
+      if****@uri*****_a?(URI::HTTP) and****@uri*****_with?("/")
+        "html"
+      else
+        File.extname(@uri.path).downcase.gsub(/\A\./, "")
+      end
     end
 
     # @return [Bool] true if MIME type is "text/XXX", false

  Modified: lib/chupa-text/input-data.rb (+1 -3)
===================================================================
--- lib/chupa-text/input-data.rb    2017-07-11 17:26:32 +0900 (5787678)
+++ lib/chupa-text/input-data.rb    2017-07-12 00:15:10 +0900 (9946cd0)
@@ -45,12 +45,10 @@ module ChupaText
 
     private
     def download
-      path =****@uri*****
-      path += "index.html" if path.end_with?("/")
       begin
         @uri.open("rb") do |input|
           self.mime_type = input.content_type.split(/;/).first
-          VirtualContent.new(input, path)
+          VirtualContent.new(input, @uri.path)
         end
       rescue OpenURI::HTTPError => error
         raise DownloadError.new(@uri, error.message.strip)
-------------- next part --------------
HTML����������������������������...
Télécharger 



More information about the Groonga-commit mailing list
Back to archive index