{"action":"created","issue":{"url":"https://api.github.com/repos/scrapy/scrapy/issues/1498","labels_url":"https://api.github.com/repos/scrapy/scrapy/issues/1498/labels{/name}","comments_url":"https://api.github.com/repos/scrapy/scrapy/issues/1498/comments","events_url":"https://api.github.com/repos/scrapy/scrapy/issues/1498/events","html_url":"https://github.com/scrapy/scrapy/pull/1498","id":106739793,"number":1498,"title":"#1487 add_scheme_if_missing for `scrapy shell` command","user":{"login":"Preetwinder","id":9640238,"avatar_url":"https://avatars.githubusercontent.com/u/9640238?v=3","gravatar_id":"","url":"https://api.github.com/users/Preetwinder","html_url":"https://github.com/Preetwinder","followers_url":"https://api.github.com/users/Preetwinder/followers","following_url":"https://api.github.com/users/Preetwinder/following{/other_user}","gists_url":"https://api.github.com/users/Preetwinder/gists{/gist_id}","starred_url":"https://api.github.com/users/Preetwinder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Preetwinder/subscriptions","organizations_url":"https://api.github.com/users/Preetwinder/orgs","repos_url":"https://api.github.com/users/Preetwinder/repos","events_url":"https://api.github.com/users/Preetwinder/events{/privacy}","received_events_url":"https://api.github.com/users/Preetwinder/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-09-16T09:56:49Z","updated_at":"2015-09-16T14:42:25Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/scrapy/scrapy/pulls/1498","html_url":"https://github.com/scrapy/scrapy/pull/1498","diff_url":"https://github.com/scrapy/scrapy/pull/1498.diff","patch_url":"https://github.com/scrapy/scrapy/pull/1498.patch"},"body":"This change addresses the enhancement mentioned in #1487.\r\n\r\nThe add_scheme_if_missing function uses the parse_url function to parse the url. It checks if the scheme is missing, if it is, 'http' is added as the default scheme. It checks if the netloc field is empty. If it is empty, it replaces it with the path field and changes the path field to empty. This is done because when handing invalid url's like \"www.example.com\" where the scheme is missing, the parse_url function(which uses urlparse itself) leaves the netloc empty and puts the entire url in path. This leads to incorrect url generation when geturl() is called.\r\n\r\nThe add_scheme_if_missing function is called by the shell command right after it extracts the url from the arguments list. A check is performed to ensure that a null value is not passed to the function.\r\n\r\nThe test tests some common url variations."},"comment":{"url":"https://api.github.com/repos/scrapy/scrapy/issues/comments/140762467","html_url":"https://github.com/scrapy/scrapy/pull/1498#issuecomment-140762467","issue_url":"https://api.github.com/repos/scrapy/scrapy/issues/1498","id":140762467,"user":{"login":"nramirezuy","id":1042865,"avatar_url":"https://avatars.githubusercontent.com/u/1042865?v=3","gravatar_id":"","url":"https://api.github.com/users/nramirezuy","html_url":"https://github.com/nramirezuy","followers_url":"https://api.github.com/users/nramirezuy/followers","following_url":"https://api.github.com/users/nramirezuy/following{/other_user}","gists_url":"https://api.github.com/users/nramirezuy/gists{/gist_id}","starred_url":"https://api.github.com/users/nramirezuy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nramirezuy/subscriptions","organizations_url":"https://api.github.com/users/nramirezuy/orgs","repos_url":"https://api.github.com/users/nramirezuy/repos","events_url":"https://api.github.com/users/nramirezuy/events{/privacy}","received_events_url":"https://api.github.com/users/nramirezuy/received_events","type":"User","site_admin":false},"created_at":"2015-09-16T14:42:25Z","updated_at":"2015-09-16T14:42:25Z","body":"This new function should be called `add_http_if_no_scheme`; it just adds `http`."}}