package com.ydl.js_module.util

import android.net.Uri
import android.text.TextUtils
import android.util.Log

/**
 * @author yuanWai
 * @描述:路由参数解析
 * @Copyright Copyright (c) 2018
 * @Company 壹点灵
 * @date 2018/12/5
 */
class RouterParamsUrls{

    constructor(url : String){
        initParam(url)
    }

    /**
     * 参数
     */
    private var params : String? = null
    /**
     * 路由uri格式
     */
    private var uri: Uri? = null

    private var method : String? = null

    private fun initParam(url : String){
        uri = Uri.parse(url)
        if (null == uri){
            return
        }
        params = url
        if (!TextUtils.isEmpty(params) && params!!.lastIndexOf("\"") == params!!.length - 1){
            params = params!!.substring(0,params!!.length - 1)
        }
        method = uri!!.host + uri!!.path.replace("/","_")
        Log.e("http", "------$method")
    }

    /**
     * 返回解析的参数
     */
    fun getParams() : String?{
        return params
    }

    fun getMethod() : String?{
        return method
    }
}