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

12
LINES

< > BotCompany Repo | #1013971 // appendQueryToURL - breaking change: process # properly

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

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

1  
static S appendQueryToURL(S url, Map params) {
2  
  if (url == null) null;
3  
  S data = makePostData(params);
4  
  if (empty(data)) ret url;
5  
  int idx = smartIndexOf(url, '#');
6  
  S url2 = takeFirst(url, idx);
7  
  ret url2 + (url2.contains("?") ? "&" : "?") + data + substring(url, idx);
8  
}
9  
10  
static S appendQueryToURL(S url, O... data) {
11  
  ret appendQueryToURL(url, paramsToMap(data));
12  
}

Author comment

Began life as a copy of #1002141

download  show line numbers  debug dex  old transpilations   

Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ekrmjmnbrukm, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1013971
Snippet name: appendQueryToURL - breaking change: process # properly
Eternal ID of this version: #1013971/9
Text MD5: 155d698f8b383964ea0c7b99eb16ab39
Transpilation MD5: c786483f7e7b1a5adc91707707c0c737
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-08-27 09:19:43
Source code size: 386 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 443 / 544
Version history: 8 change(s)
Referenced in: [show references]