@Override
    public String permalink(Category category) {
        Map<String, String> annotations = MetadataUtil.nullSafeAnnotations(category);
        String permalinkPrefix =
            annotations.getOrDefault(Constant.PERMALINK_PATTERN_ANNO, DEFAULT_PERMALINK_PREFIX);
        String slug = encode(category.getSpec().getSlug(), StandardCharsets.UTF_8);
        String path = PathUtils.combinePath(permalinkPrefix, slug);
        return externalUrlSupplier.get()
            .resolve(path)
            .normalize().toString();
    }
@Test
    void permalink() {
        Category category = new Category();
        Metadata metadata = new Metadata();
        metadata.setName("category-test");
        category.setMetadata(metadata);
        Category.CategorySpec categorySpec = new Category.CategorySpec();
        categorySpec.setSlug("slug-test");
        category.setSpec(categorySpec);

        when(externalUrlSupplier.get()).thenReturn(URI.create(""));
        String permalink = categoryPermalinkPolicy.permalink(category);
        assertThat(permalink).isEqualTo("/categories/slug-test");

        when(externalUrlSupplier.get()).thenReturn(URI.create("http://exmaple.com"));
        permalink = categoryPermalinkPolicy.permalink(category);
        assertThat(permalink).isEqualTo("http://exmaple.com/categories/slug-test");
        String path = URI.create(permalink).getPath();
        assertThat(path).isEqualTo("/categories/slug-test");

        category.getSpec().setSlug("中文 slug");
        permalink = categoryPermalinkPolicy.permalink(category);
        assertThat(permalink).isEqualTo("http://exmaple.com/categories/%E4%B8%AD%E6%96%87%20slug");
    }