Handler to convert BBS links to macscripter.net, it use lastPathComponent from Foundation.
use framework "Foundation"
(**
* INPUT: "http://bbs.applescript.net/viewtopic.php?id=15030"
* OUTPUT: "https://www.macscripter.net/viewtopic.php?id=15030"
*)
log bbsURLToMacscripterNet("http://bbs.applescript.net/viewtopic.php?id=15030")
on bbsURLToMacscripterNet(theURL)
set theURL to current application's |NSURL|'s fileURLWithPath:theURL
return "https://www.macscripter.net/" & (theURL's lastPathComponent() as text)
end bbsURLToMacscripterNet
And if we like to do Automator Service to convert URL to store in clipboard
Run AppleScript Action:
use framework "Foundation"
use scripting additions
on run {input, parameters}
set the clipboard to (bbsURLToMacscripterNet(item 1 of input)) as text
end run
on bbsURLToMacscripterNet(theURL)
set theURL to current application's |NSURL|'s fileURLWithPath:theURL
return "https://www.macscripter.net/" & (theURL's lastPathComponent() as text)
end bbsURLToMacscripterNet