JavaScriptã«ããRFC6570 - URI Templateã®å®è£
JavaScriptã§å®è£
ããã®ãdraftã¬ãã«ã®ããè¦ã¤ãããªãã£ãã®ã§ä½ã£ã¦ã¿ã¾ããã
(âLv4ã¾ã§å¯¾å¿ãã¦ãã®ãæãã¾ãããã§ããã£ããä½ã£ãã®ã§å¼ãç¶ãå
¬éãã¦ããã¾ãã)
URI Templateã£ã¦ï¼
ç°¡åã«è¨ãã¨URIã«ç¹åãããã³ãã¬ã¼ãã¨ã³ã¸ã³ã§ãã
ãhttp://www.example.com/users/{userid:1}/{userid}/ãã£ã¦æ¸ãã¨ãã¦ãhttp://www.example.com/users/t/test/ãã£ã¦æååä½ããã便å©ã ããï¼ï¼
詳ããã¯ä»¥ä¸ãåèã«ãã¦ãã ããã
以ä¸ãããæã¡å¸°ããã ããã
githubãjsdo.itãåãã¦ä½¿ãã®ã§ããããã£ããæãã¦ãã ããã
ã¹ã¯ãªããæ¬ä½ã¯ãã¡ã
gitgubâhttps://github.com/s025236/URI-Template
jsdo.itâhttp://jsdo.it/s025236/URI-Template-0.1
ãã¹ãã³ã¼ãã¯ãã¡ã
âhttp://jsdo.it/s025236/URI-Template-0.1.test
使ãæ¹
ã¾ãã¯scriptã¿ã°ã§ãã¼ããã¾ãã
<script src="https://raw.github.com/s025236/URI-Template/master/URI-Template.js"></script>
ãã¨ã¯URI_Template::parseããã ãã§ãã
//window.useridãåç §ãã¦ãã¼ã¹çµæãè¿ãã¾ãã URI_Template::parse('http://www.example.com/users/{userid}/'); //ãªãã¸ã§ã¯ããåç §ãã¦ãã¼ã¹çµæãè¿ãã¾ãã URI_Template::parse('http://www.example.com/users/{userid}/',{'userid' : 'test'});
ä»æ§ã¨ä¸ä¸è´
RFCå ã«è²ã ãµã³ãã«ãããã®ã§ãã以ä¸ã®çç±ã«ããããã¤ããã¹ããéãã¾ããã
- JavaScriptã«ã!ãã¯ã¨ã¹ã±ã¼ãããªããã©ã/ãã¯ããé¢æ°ãªãã¦ç¥ããªããâ¦
- OPã³ã¼ããã;ãã®æã ããªãã§å¦çéãã®ï¼RFCãããããããããã
æå¾ã«
å¿æ´ã³ã¡ã³ããå¾
ã¡ãã¦ããã¾ãã
ä¸å
·åå ±åã使ç¨ä¾çããã¾ããããæ¯éãé£çµ¡ãã ããã