블로그 이미지
푸른_바람

Rss feed Tistory
IT/Tech 2010/11/01 08:30

javascript parse url

참고

[code javascript] // parseUri 1.2.2 // (c) Steven Levithan // MIT License // http://blog.stevenlevithan.com/archives/parseuri // Demo : http://stevenlevithan.com/demo/parseuri/js/ function parseUri (str) { var o = parseUri.options, m = o.parser[o.strictMode ? "strict" : "loose"].exec(str), uri = {}, i = 14; while (i--) uri[o.key[i]] = m[i] || ""; uri[o.q.name] = {}; uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) { if ($1) uri[o.q.name][$1] = $2; }); return uri; }; parseUri.options = { strictMode: false, key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"], q: { name: "queryKey", parser: /(?:^|&)([^&=]*)=?([^&]*)/g }, parser: { strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ } }; [/code]

'IT > Tech' 카테고리의 다른 글

eclipse "java heap space"  (0) 2010/11/03
svn: No repository found in svn://xxx.xxx.xxx.xxx/trunk  (0) 2010/11/02
javascript parse url  (0) 2010/11/01
js 함수 및 클래스 존재여부 확인  (0) 2010/10/29
ubuntu apm 설치  (0) 2010/10/21
facebook API Quick Guide (CodeIgniter)  (0) 2010/10/15
IT/그외... 2010/03/08 13:56

mypickup short url api

현재 mypickup aip는 결과를 json만 표현하고 있습니다.

사용방법은 아래 스크핍트 방식을 참고해서 어떤 개발언어에서든지 HTTP로 사용가능합니다.

[code javascript]
var url = 'http://2u.lc/?c=api&m=short&q='+ encodeURIComponent('daum.net');
window.open(url, 'short_url', '');
[/code]

[code html]
{
"uri_idx":"24",
"uri_scheme":"http",
"uri_host":"daum.net",
"uri_path":null,
"uri_query":null,
"uri":"http:\/\/daum.net",
"uri_fragment":null,
"uri_jump":"18",
"short_numalpha":"http:\/\/2u.lc\/O",
"short_kor":"http:\/\/2u.lc\/\uac18"
}
[/code]

uri_idx : uri 고유번호
uri : uri 전체 주소
uri_jump : uri 방문 횟수 (2u.lc & mypickup 서비스를 사용한 카운터 횟수 )
short_numalpha : short url 주소
short_kor : short url 주소

결과 참고 페이지 :
- http://2u.lc/api/short/bluebreeze.co.kr
- http://2u.lc/?c=api&m=short&q=http://bluebreeze.co.kr/397

IT/HTML+JS+CSS+ 2009/04/25 12:07

URI와 링크

* URI와 링크
 - 웹에서 다양한 페이지를 오갈 수 잇는 이유는 페이지들이 URI를 기본으로한 '링크'로 연결되어 있기 때문이다.

** URI 스킴(URI schmes)
 - http://www.iana.org/assignments/uri-schemes.html
 - RFC 3986 'Uniform Resource Identifier (URI):  Generic Syntax
  -- http://www.ietf.org/rfc/rfc3986.txt
 - W3C 주석 'URIs, URLs, and URNs : Clarifications and Recommendations 1.0'
  -- http://www.w3.org/TR/uri-clarification
 - 보통의 웹 페이지는 http: 스킴을 이용
 - FTP서버에 접근하기 위한 ftp: 스킴, 이메일 조주소를 지정하기 위한 mailto: 스킴 등 IANA 'Uniform Resource Identifier(URI) Schemes'에는 gopher: 스킴 news: 스킴등 40종류 이상의 공식 URI스킴이 등록되어있다.
 - http: 스킴 서식은 RFC 1738과 RFC 2396 등에서 아래와 같이 규정 되어있다.
  -- http://<authority><path>
  -- http://<authority><path>?<query>
  -- http://<authority><path>#<fragment>
  -- 규정 다음으로 '?'로 구별되는 쿼리부분(query component)과 '#'로 구별되는 프래그먼트 식별자(Fragment Identifier)를 지정할 수 있다.

*** 책임자 부분(authorigy component)
 - '//' 네트워크상의 리소스임을 나타낸다.
 - 끝 부분 ':'  서버의 포트번호를 지정
 - 책임자 부분에는 알파벳 또는 -(하이폰)만 사용할 수 있다

*** 패스 부분(path component)
 - 폴더명과 파일부분으로 구성된다.
 - 서버 내부 자원의 위치를 나타낸다.
 - 임의로 이름을 붙일 수 잇다.
 - 폴더 계층은 '/'로 구별 규정.
 - '.html'은 '확장자'라 하며 그 자원이 (X)HTML 형식으로 작성, 보존되었음((X)HTML 문서임)을 의미한다.
 - '.html' 이외에 '.htm'이 사용되기도 한다.

** 절대 URI
 - URI를 URI스킴에서 패스까지 전부 적는 것을 말하며 웹 전체에서 본 URI이다.
 - 일반적으로 URI라 하면 절대URI를 가르킨다.
 - 일반적으로 URI에서 파일명이 생략된 경우 'index.html'(또는 'index.htm', IIS에서는 'default.html")이 기본파일로 설정되어 있다.
 - Apache 서버라면 .htaccess파일에 다음과 같이 설정하여 파일의 기본값(단일, 복수)을 지정할 수 있다.
  -- DirectoryIndex top.html
  -- DirectoryIndx index.html index.cgi index.php
 - URI가 폴더명으로 끝날경우 '/'를 확실히 붙여야 한다.

** 상대 RUI
 - 어떤 파일과 폴더를 기저믕로 하는 다른 파일과의 경로.
 - 같은 폴더안의 파일을 참고할 경우
  -- ./site.html
  -- site.html
 - 한단계 위 폴더의 파일을 참조
  -- ../reports/index.html
  -- '..'는 한 단계 위를 나타낸다.

'IT > HTML+JS+CSS+' 카테고리의 다른 글

CSS odd & even rules  (0) 2010/08/11
리눅스용 텍스트 브라우즈 w3m  (0) 2010/08/05
URI와 링크  (0) 2009/04/25
블록 레벨 요소(block-level elements)  (0) 2009/04/24
네비게이션 링크  (0) 2009/04/24
XHTML BASE  (0) 2009/04/24
TOTAL 245,655 TODAY 22