Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

6
LINES

< > BotCompany Repo | #1032379 // addDefaultProtocolToURL

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3342L/18K).

1  
sS addDefaultProtocolToURL(S protocol, S url) {
2  
  if (empty(url)) ret url;
3  
  if (regexpFindIC("^[a-z]+://", url)) ret url;
4  
  protocol = dropSuffix(":", dropSuffix("//", protocol));
5  
  ret protocol + ":" + addPrefix("//", url);
6  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx

No comments. add comment

Snippet ID: #1032379
Snippet name: addDefaultProtocolToURL
Eternal ID of this version: #1032379/5
Text MD5: 84b82ea1749cc41f7118f9e8963c4801
Transpilation MD5: 3cba2c0a6c993b83d0ee3a285d9c8fc3
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-09-02 02:51:37
Source code size: 232 bytes / 6 lines
Pitched / IR pitched: No / No
Views / Downloads: 156 / 224
Version history: 4 change(s)
Referenced in: [show references]