https://gist.github.com/jxson/963339/33a0623a000334aa0ab97def069c3902a1212f6c
해NJ17; URL1012; 참1312;Ȣ16;여, 아래1032; js를 실행Ȣ16;였1004;나, 에러가 0156;생Ȣ16;네요
해NJ17; 문1244;1216; 해결1012; 위Ȣ16;여, 1312;Ǻ16; ǥ12;ᓠ1; 드/140; 봅니다.
감사합니다.
160;
----- 실행 화면 (에러 0156;생)
10095; bitly http://www.naver.com
/opt/homebrew/bin/bitly.js:3
160; 160; 160; 160; link = process.ARGV[2],
160; 160; 160; 160; 160; 160; 160; 160; 160; 160; 160; 160; 160; 160;^ # <======================================== !!!
TypeError: Cannot read properties of undefined (reading '2')
160; 160; at Object.<anonymous> (/opt/homebrew/bin/bitly.js:3:22)
160; 160; at Module._compile (node:internal/modules/cjs/loader:1218:14)
160; 160; at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
160; 160; at Module.load (node:internal/modules/cjs/loader:1081:32)
160; 160; at Module._load (node:internal/modules/cjs/loader:922:12)
160; 160; at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:82:12)
160; 160; at node:internal/main/run_main_module:23:47
Node.js v19.3.0
----- 1204;체 코드
10095; \cat /opt/homebrew/bin/bitly.js
var request = require('request'),
160; 160; 160; 160; sys = require('sys'),
160; 160; 160; 160; link = process.ARGV[2],
160; 160; 160; 160; bitly = 'http://api.bit.ly/v3/shorten';
function urlencode(str) {
return escape(str)
160; 160; .replace('+', '%2B')
160; 160; .replace('%20', '+')
160; 160; .replace('*', '%2A')
160; 160; .replace('/', '%2F').replace('@', '%40');
}
// prepend http if it does not exist.
if (!/^https?:\/\//i.test(link)) {
160; 160; link = 'http://' + link;
}
// urlencode the link and add to params.
var params = 'login=YOUR_LOGIN_ID&apiKey=YOUR_API_KEY&longUrl='+urlencode(link)+'%2F&format=json';
request({uri:bitly, body:params, method:'POST'},function(error,response,body){
160; 160; if(!error && response.statusCode === 200 && body)
160; 160; {
160; 160; 160; 160; var json = JSON.parse(body);
160; 160; 160; 160; console.log(json.data.url);
160; 160; }
});
¾Ë·Á ÁֽŠÁ¶Ä¡´ë·Î ÇÏ¿© ±âÁ¸ÀÇ ¹®Á¦Á¡Àº ¹ß»ýÇÏÁö ¾ÊÀ¸³ª,
ÀǵµÇÑ °á°ú °ªÀÌ ¾Æ´Ñ ´Ù¸¥ °ªÀÌ Ãâ·ÂÀÌ µÇ¼¿ä
10095; bitly www.google.com
10095;
10095; undefined # <======== cltr + v
¸Þ¸ðÀå¿¡ clipboard¿¡ ÀúÀåµÈ °á°ú °ªÀ» º¹»ç¸¦ Çغ¸¸é,
undefined
ÀÌ·± °ªÀ» Âï°í ÀÖ±â´Â ÇÕ´Ï´Ù. ²Ù¹÷ ~.~