Permalink
Browse files

use _EncodeUrl() in _Shorten

  • Loading branch information...
1 parent 3092d4c commit 376d4a7f4110eef56489fc3ed308bfeace6c0926 @nimdahk committed Sep 9, 2011
Showing with 7 additions and 8 deletions.
  1. +3 −5 AHKLink.ahk
  2. +2 −2 tests/AHKLink.ahk
  3. +2 −1 tests/AHKLink_TSVRet.ahk
View
@@ -47,14 +47,12 @@ AHKLink_ForumSearch(SearchText, ByRef OutTitle = 0)
AHKLink_Shorten(Link)
{
- static rep := "&|%26,=|%3D,?|%3F,#|%23,:|%3A,/|%2F, |%20,~|%7E"
- , endpoint := "http://api.bitly.com/v3/shorten?login=ahk4me&apiKey=R_4b3df1f5417d94ff356ed511fd50a153&format=txt&longUrl="
+ static endpoint := "http://api.bitly.com/v3/shorten?login=ahk4me&apiKey=R_4b3df1f5417d94ff356ed511fd50a153&format=txt&longUrl="
If RegExMatch(Link, "i)^(?:http://)?www.autohotkey.net/~Lexikos/AutoHotkey_L/docs/commands/(.*?).htm(#.*)?$", match)
return "http://d.ahk4.me/~" . match1 . match2
If RegExMatch(Link, "i)^(?:http://)?www.autohotkey.net/~Lexikos/AutoHotkey_L/docs/(.*?).htm(#.*)?$", match)
return "http://d.ahk4.me/" . match1 . match2
- Loop Parse, rep, `,
- StringReplace, Link, Link, % SubStr(A_LoopField, 1, 1), % SubStr(A_LoopField, 3), All
+ link := AHKLink_EncodeUrl(link)
UrlDownloadToFile
, %endpoint%%Link%
, % fn := A_Temp "\BitlyAHK4MEAHKLinkShorten.tmp"
@@ -109,7 +107,7 @@ AHKLink_EncodeUrl(Text){
SetFormat, integer, hex
Loop Parse, Text
If A_loopField is not alnum
- r .= "%" . SubStr(Asc(A_LoopField), 3)
+ r .= "%" . SubStr("0" . SubStr(Asc(A_LoopField), 3), -1)
else r.= A_LoopField
SetFormat, integer, %f%
return r
View
@@ -8,8 +8,8 @@ MsgBox % clipboard := AHKLink("IfWinActive") ; http://www.autohotkey.net/~Lexiko
MsgBox % clipboard := AHKLink("IfWinActive", Forcebasic := 1) ; http://www.autohotkey.com/docs/commands/IfWinActive.htm
; From the forum and documentation Search: (note that the forcebasic parameter will be ignored)
-; Many consider the forum search inadequate, and this returns a link which contains the words IfWinActive,Help,Needed but not all together.
-MsgBox % clipboard := AHKLink("IfWinActive help needed", 0, ShortLink := 0, ForceSearch := 1) ; http://www.autohotkey.com/forum/topic33341-30.html
+; Many consider the forum search inadequate, and this returns a link which contains the words IfWinActive and help, but might be unreliable.
+MsgBox % clipboard := AHKLink("IfWinActive help", 0, ShortLink := 0, ForceSearch := 1) ; http://www.autohotkey.com/forum/topic21497.html
; Let's test the link shortening:
MsgBox % clipboard := AHKLink("IfWinActive", Forcebasic := 0, ShortLink := 1) ; http://d.ahk4.me/~IfWinActive
View
@@ -1,4 +1,5 @@
#Include ..\AHKLink.ahk
SetWorkingDir .. ; the index file is way over there in the parent directory
MsgBox % AHKLink_TSVRet("#Delimiter") ; AutoHotkey_L - http://www.autohotkey.net/~Lexikos/AutoHotkey_L/docs/commands/_EscapeChar.htm#Delimiter
-MsgBox % AHKLink_TSVRet("#Delimiter", 1) ; sets ForceBasic - http://www.autohotkey.com/docs/commands/_EscapeChar.htm#Delimiter
+MsgBox % AHKLink_TSVRet("#Delimiter", 1) ; sets ForceBasic - http://www.autohotkey.com/docs/commands/_EscapeChar.htm#Delimiter
+MsgBox % AHKLink_TSVRet("Hotkeys", 0)

0 comments on commit 376d4a7

Please sign in to comment.