Update internet link format
This commit is contained in:
parent
c5221f523b
commit
cac22d8951
|
@ -79,7 +79,7 @@ Public Function ToAddress() As String
|
||||||
Select Case system_
|
Select Case system_
|
||||||
Case PT_MOBILE: ToAddress = Fmt("http://mobileonline.garant.ru/document/redirect/{1}/{2}", gid_, sBookmarkID)
|
Case PT_MOBILE: ToAddress = Fmt("http://mobileonline.garant.ru/document/redirect/{1}/{2}", gid_, sBookmarkID)
|
||||||
Case PT_LOCAL: ToAddress = Fmt("garantf1://{1}.{2}/", gid_, sBookmarkID)
|
Case PT_LOCAL: ToAddress = Fmt("garantf1://{1}.{2}/", gid_, sBookmarkID)
|
||||||
Case PT_INTERNET: ToAddress = Fmt("http://internet.garant.ru/document/redirect/{1}/{2}", gid_, sBookmarkID)
|
Case PT_INTERNET: ToAddress = Fmt("https://internet.garant.ru/document/redirect/{1}/{2}", gid_, sBookmarkID)
|
||||||
End Select
|
End Select
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ Private Function CutPrefix(aLink$, iSystem As TLinkSystem) As String
|
||||||
CutPrefix = VBA.Right(aLink, VBA.Len(aLink) - VBA.InStr(1, aLink, "//") - 1)
|
CutPrefix = VBA.Right(aLink, VBA.Len(aLink) - VBA.InStr(1, aLink, "//") - 1)
|
||||||
CutPrefix = VBA.Left(CutPrefix, VBA.Len(CutPrefix) - 1)
|
CutPrefix = VBA.Left(CutPrefix, VBA.Len(CutPrefix) - 1)
|
||||||
Case PT_INTERNET
|
Case PT_INTERNET
|
||||||
CutPrefix = VBA.Right(aLink, VBA.Len(aLink) - 44) ' 44 = Len(PrefixFor(PT_INTERNET))
|
CutPrefix = VBA.Right(aLink, VBA.Len(aLink) - 45) ' 45 = Len(PrefixFor(PT_INTERNET))
|
||||||
CutPrefix = VBA.Replace(CutPrefix, "/", ".")
|
CutPrefix = VBA.Replace(CutPrefix, "/", ".")
|
||||||
End Select
|
End Select
|
||||||
If Not CutPrefix Like "*.*" Then _
|
If Not CutPrefix Like "*.*" Then _
|
||||||
|
@ -109,7 +109,7 @@ Private Function PrefixFor(aType As TLinkSystem) As String
|
||||||
Select Case aType
|
Select Case aType
|
||||||
Case PT_MOBILE: PrefixFor = "http://mobileonline.garant.ru/document/redirect/"
|
Case PT_MOBILE: PrefixFor = "http://mobileonline.garant.ru/document/redirect/"
|
||||||
Case PT_LOCAL: PrefixFor = "garantf1://"
|
Case PT_LOCAL: PrefixFor = "garantf1://"
|
||||||
Case PT_INTERNET: PrefixFor = "http://internet.garant.ru/document/redirect/"
|
Case PT_INTERNET: PrefixFor = "https://internet.garant.ru/document/redirect/"
|
||||||
End Select
|
End Select
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ Public Function t_Init()
|
||||||
Call Dev_ExpectEQ(PT_LOCAL, iDoc_.linkSystem_)
|
Call Dev_ExpectEQ(PT_LOCAL, iDoc_.linkSystem_)
|
||||||
|
|
||||||
Call Dev_NewCase("IVO garant")
|
Call Dev_NewCase("IVO garant")
|
||||||
doc.Hyperlinks(1).Address = "http://internet.garant.ru/document/redirect/1339/0"
|
doc.Hyperlinks(1).Address = "https://internet.garant.ru/document/redirect/1339/0"
|
||||||
Set iDoc_ = New InfoDocument
|
Set iDoc_ = New InfoDocument
|
||||||
Call Dev_ExpectTrue(iDoc_.Init(doc))
|
Call Dev_ExpectTrue(iDoc_.Init(doc))
|
||||||
Call Dev_ExpectEQ(doc.Name, iDoc_.doc_.Name)
|
Call Dev_ExpectEQ(doc.Name, iDoc_.doc_.Name)
|
||||||
|
@ -120,7 +120,7 @@ Public Function t_CreateTitleLink()
|
||||||
iDoc_.gid_ = 123
|
iDoc_.gid_ = 123
|
||||||
|
|
||||||
Call iDoc_.CreateTitleLink
|
Call iDoc_.CreateTitleLink
|
||||||
Dim sAddr$: sAddr = "http://internet.garant.ru/document/redirect/123/0"
|
Dim sAddr$: sAddr = "https://internet.garant.ru/document/redirect/123/0"
|
||||||
Call Dev_AssertEQ(1, doc.Hyperlinks.Count, "Hyperlink count")
|
Call Dev_AssertEQ(1, doc.Hyperlinks.Count, "Hyperlink count")
|
||||||
Call Dev_ExpectEQ("test1", doc.Hyperlinks(1).Range.Text, "Hyperlink range")
|
Call Dev_ExpectEQ("test1", doc.Hyperlinks(1).Range.Text, "Hyperlink range")
|
||||||
Call Dev_ExpectEQ(sAddr, doc.Hyperlinks(1).Address, "Hyperlink address")
|
Call Dev_ExpectEQ(sAddr, doc.Hyperlinks(1).Address, "Hyperlink address")
|
||||||
|
|
|
@ -9,9 +9,6 @@ Attribute VB_PredeclaredId = False
|
||||||
Attribute VB_Exposed = False
|
Attribute VB_Exposed = False
|
||||||
Option Explicit
|
Option Explicit
|
||||||
|
|
||||||
' TODO:
|
|
||||||
' Public Function ValidateSync(itLink As IteratorLinkCached)
|
|
||||||
|
|
||||||
Private iLink_ As ItemHyperlink
|
Private iLink_ As ItemHyperlink
|
||||||
|
|
||||||
Public Function Setup()
|
Public Function Setup()
|
||||||
|
@ -63,7 +60,7 @@ Public Function t_ToAddress()
|
||||||
|
|
||||||
Call Dev_NewCase("IVO garant")
|
Call Dev_NewCase("IVO garant")
|
||||||
Call iLink_.Init(PT_INTERNET, 1337)
|
Call iLink_.Init(PT_INTERNET, 1337)
|
||||||
Call Dev_ExpectEQ("http://internet.garant.ru/document/redirect/1337/0", iLink_.ToAddress)
|
Call Dev_ExpectEQ("https://internet.garant.ru/document/redirect/1337/0", iLink_.ToAddress)
|
||||||
|
|
||||||
Call Dev_NewCase("Custom sub")
|
Call Dev_NewCase("Custom sub")
|
||||||
Call iLink_.Init(PT_LOCAL, 1337, "sub_123")
|
Call iLink_.Init(PT_LOCAL, 1337, "sub_123")
|
||||||
|
@ -90,11 +87,11 @@ Public Function t_FromString()
|
||||||
Call Dev_ExpectEQ(PT_LOCAL, iLink_.LinkSystem, "Do not reset on failed load")
|
Call Dev_ExpectEQ(PT_LOCAL, iLink_.LinkSystem, "Do not reset on failed load")
|
||||||
|
|
||||||
Call Dev_ExpectFalse(iLink_.FromAddress("invalid"), "Invalid input")
|
Call Dev_ExpectFalse(iLink_.FromAddress("invalid"), "Invalid input")
|
||||||
Call Dev_ExpectFalse(iLink_.FromAddress("http://internet.garant.ru/document/redirect/"), "Missing GID")
|
Call Dev_ExpectFalse(iLink_.FromAddress("https://internet.garant.ru/document/redirect/"), "Missing GID")
|
||||||
Call Dev_ExpectFalse(iLink_.FromAddress("http://internet.garant.ru/document/redirect/123/"), "Missing SUB")
|
Call Dev_ExpectFalse(iLink_.FromAddress("https://internet.garant.ru/document/redirect/123/"), "Missing SUB")
|
||||||
Call Dev_ExpectFalse(iLink_.FromAddress("garantf1://1338.3"), "Missing slash")
|
Call Dev_ExpectFalse(iLink_.FromAddress("garantf1://1338.3"), "Missing slash")
|
||||||
Call Dev_ExpectFalse(iLink_.FromAddress("http://internet.garant.ru/document/redirect/abc/1"), "Invalid GID")
|
Call Dev_ExpectFalse(iLink_.FromAddress("https://internet.garant.ru/document/redirect/abc/1"), "Invalid GID")
|
||||||
Call Dev_ExpectFalse(iLink_.FromAddress("http://internet.garant.ru/document/redirect/123/abc"), "Invalid SUB")
|
Call Dev_ExpectFalse(iLink_.FromAddress("https://internet.garant.ru/document/redirect/123/abc"), "Invalid SUB")
|
||||||
|
|
||||||
Call Dev_NewCase("Mobile garant")
|
Call Dev_NewCase("Mobile garant")
|
||||||
Call Dev_ExpectTrue(iLink_.FromAddress("http://mobileonline.garant.ru/document/redirect/1337/2"))
|
Call Dev_ExpectTrue(iLink_.FromAddress("http://mobileonline.garant.ru/document/redirect/1337/2"))
|
||||||
|
@ -109,7 +106,7 @@ Public Function t_FromString()
|
||||||
Call Dev_ExpectEQ("sub_3", iLink_.BookmarkName)
|
Call Dev_ExpectEQ("sub_3", iLink_.BookmarkName)
|
||||||
|
|
||||||
Call Dev_NewCase("IVO garant")
|
Call Dev_NewCase("IVO garant")
|
||||||
Call Dev_ExpectTrue(iLink_.FromAddress("http://internet.garant.ru/document/redirect/1339/4"))
|
Call Dev_ExpectTrue(iLink_.FromAddress("https://internet.garant.ru/document/redirect/1339/4"))
|
||||||
Call Dev_ExpectEQ(PT_INTERNET, iLink_.LinkSystem)
|
Call Dev_ExpectEQ(PT_INTERNET, iLink_.LinkSystem)
|
||||||
Call Dev_ExpectEQ(1339, iLink_.DocumentID)
|
Call Dev_ExpectEQ(1339, iLink_.DocumentID)
|
||||||
Call Dev_ExpectEQ("sub_4", iLink_.BookmarkName)
|
Call Dev_ExpectEQ("sub_4", iLink_.BookmarkName)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user