{"id":6654,"date":"2012-12-11T12:18:27","date_gmt":"2012-12-11T17:18:27","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=6654"},"modified":"2012-12-11T12:21:10","modified_gmt":"2012-12-11T17:21:10","slug":"nsurl-path-handling","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2012\/12\/11\/nsurl-path-handling\/","title":{"rendered":"NSURL Path Handling"},"content":{"rendered":"<p><a href=\"http:\/\/www.mikeabdullah.net\/a-pair-of-url-path-handling.html\">Mike Abdullah<\/a>:<\/p>\n<blockquote cite=\"http:\/\/www.mikeabdullah.net\/a-pair-of-url-path-handling.html\"><p>So the end result here is that if you need to remove the last path component of a URL and stand a chance of being passed in one ending in two or more slashes you&rsquo;re kinda stuck.<\/p><\/blockquote>\n<p>I&rsquo;ve always thought it a good idea to standardize paths and URLs, to get rid of any <tt>.<\/tt> or <tt>..<\/tt> components. Otherwise, trying to get the filename or the container URL may give an unexpected result. But this example shows that sometimes even that isn&rsquo;t enough. <code>NSURL<\/code>s are better than <code>NSString<\/code>s, but in my view Cocoa still doesn&rsquo;t handle file stuff properly.<\/p>","protected":false},"excerpt":{"rendered":"<p>Mike Abdullah: So the end result here is that if you need to remove the last path component of a URL and stand a chance of being passed in one ending in two or more slashes you&rsquo;re kinda stuck. I&rsquo;ve always thought it a good idea to standardize paths and URLs, to get rid of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[131,69,54,71],"class_list":["post-6654","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-bug","tag-cocoa","tag-objective-c","tag-programming"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/6654","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=6654"}],"version-history":[{"count":2,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/6654\/revisions"}],"predecessor-version":[{"id":6656,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/6654\/revisions\/6656"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=6654"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=6654"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=6654"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}