当前位置:网站首页>URL return nil and urlhash processing
URL return nil and urlhash processing
2022-07-27 17:05:00 【CAir2】
In project practice , Find out URL In some system versions (14.7.1) Returns the nil( Even if there is no Chinese ), So it's using URL It is best to code as follows :
Before we know this, we should know url in #(hash) The meaning of
Swift3 Before :
url.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)
Swift3:
// code
url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
// decode
url.removingPercentEncoding
Yes String Expand :
extension String{
public func toURL()->URL?{
// If url with hash Do not deal with
let range = range(of: "/#/")
if range != nil{
let Url = URL(string: self)
return Url
}
let eurl = addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
if eurl != nil{
let Url = URL(string: eurl!)
return Url
}
return nil
}
}
边栏推荐
- Apache
- 从零开始Blazor Server(1)--项目搭建
- mysql视图及存储过程
- log4j.jar和slf4-log4下载链接
- 牛客题目——用两个栈实现队列、包含min函数的栈、有效括号序列
- Advanced pointer of C language
- JDBC connection database
- Servlet Chinese garbled setcontenttype setting is invalid
- Circular statements and arrays
- If you don't want to step on those holes in SaaS, you must first understand the "SaaS architecture"
猜你喜欢
随机推荐
Xcode 发布测试包TestFlight
Cryptography series: certificate format representation of PKI X.509
C语言之文件操作
全局String对象(函数类型)+Math对象
Stylelint check error: unexpected missing generic font family font family no missing generic family keyword
JSP El expression, JSTL tag
分享一个网上搜不到的「Redis」实现「聊天回合制」的方案
Servlet中文乱码setContentType设置无效
Database notes sorting
2021-05-30
内置对象(下)
JDBC程序实现完整步骤
2021-06-18 SSM项目中自动装配错误
The bill module of freeswitch
Shell programming specifications and variables
C语言之数据的储存
LOJ 510 - "libreoj noi round 1" memories outside the north school gate [line segment tree]
Niuke topic -- Realizing queues with two stacks, stacks containing min functions, and valid bracket sequences
meta-data 占位符的引用
三表联查3









