             on_download  : ((a) => @setState(download: a))
             # TODO: Render error in useful location
             on_error     : ((a) => @setState(error: a))
-        if not @state.error?
+        if not @state?.error?
             @props.actions.setState(file_search : '', page_number: 0)
 
     # Default to sagews if none is given.
     extension : ->
-        if @props.file_search?.indexOf('.') == -1
+        if @props.file_search?.lastIndexOf('.') <= @props.file_search?.lastIndexOf('/')
           "sagews"
 
     # Go to the new file tab if there is no file search

                </span>
                <hr/>
                {@render_new_button() if not @props.public_view}
                {@render_file_type_selection() if @props.file_search?.length > 0}
            </Col>
            <Col sm=2>

                on_submit     = {@search_submit}
            />
            {@render_create_file_warning()}
            {@render_help_info()}
        </span>

ProjectFilesNew = rclass
