rrl.appjet.net
/* appjet:version 0.1 */ var url = request.params.url if (url) { try { wget(url, {}, {followRedirects: false}) } catch(e) { if(e.message.toString().match(/3../)) { page.setMode('plain') print(e.info.headers.Location[0]) } } } else { print(H1('Return Redirected Location')) print(H2('example')) print(PRE('http://rrl.appjet.net/?url=http://mbp.tumblr.com/random')) }
wget(url, params, options)
AppJet JavaScript Library Reference
Fetches the text of a URL and returns it as a string.
object options? Optional object with three optional properties:
AppJet JavaScript Library Reference
- headers: HTTP request headers to send with the GET, as a dictionary of {name: value} entries.
- followRedirects: A boolean indicating whether to follow redirect headers returned by the server. Defaults to true.
- complete: If true, wget returns an object containing all information about the response, not just its contents. Otherwise, wget throws a HttpRequestError if it encounters an error GETing.
new HttpRequestError(message, info)
AppJet JavaScript Library Reference
The error thrown by wget and wpost if there's a problem retrieveing the requested URL.
try〜catch文
try〜catch文は、tryに続くブロック(複文)部分で囲んだプログラム中で、なんらかのエラーが発生したときに、catch節を使ってエラーの内容を受け取るものである。 デバッグ中に、そのバグの内容を受け取ることが出来るので、ここでエラーの内容をはき出す様にしておくと、バグの箇所と特定するのに大変役に立つ。
try{ // 何らかのプログラム }catch( e ){ alert( e ); // バグの内容をダイアログで表示する }JavaScript try-catch文 - Wikibooks