> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xray.cool/llms.txt
> Use this file to discover all available pages before exploring further.

# dir

> `dir`函数主要是用来返回 URL 的路径

## 函数原型

`func dir(s1 string) string`

### 参数介绍

| 参数名称 | 参数介绍 |
| - | - |
| s1 | 待转换的数据 |

## 举例

| 待转换数据 | 转换语句 | 输出结果 |
| - | - | - |
| `https://docs.xray.cool/a/b` | `dir("https://docs.xray.cool/a/b")` | `https://docs.xray.cool/a/` |
| `/a/b` | `dir("/a/b")` | `/a/` |
| `a/b/c` | `dir("a/b/c")` | `a/b/` |
| `a/` | `dir("a/")` | `a/` |
| `/` | `dir("/")` | `/` |
| `/a` | `dir("/a")` | `/` |
| `a` | `dir("a")` | `""` |
| `""` | `dir("")` | `""` |
| `./../../a` | `dir("./../../a")` | `./../../` |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.