mirror of
https://github.com/Finb/Bark.git
synced 2025-12-08 21:36:01 +00:00
24 lines
539 B
Swift
24 lines
539 B
Swift
//
|
|
// String+Extension.swift
|
|
// Bark
|
|
//
|
|
// Created by huangfeng on 2018/6/26.
|
|
// Copyright © 2018 Fin. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
extension String {
|
|
//将原始的url编码为合法的url
|
|
func urlEncoded() -> String {
|
|
let encodeUrlString = self.addingPercentEncoding(withAllowedCharacters:
|
|
.urlQueryAllowed)
|
|
return encodeUrlString ?? ""
|
|
}
|
|
|
|
//将编码后的url转换回原始的url
|
|
func urlDecoded() -> String {
|
|
return self.removingPercentEncoding ?? ""
|
|
}
|
|
}
|