@Override
    public String permalink(Tag tag) {
        Map<String, String> annotations = MetadataUtil.nullSafeAnnotations(tag);
        String permalinkPrefix =
            annotations.getOrDefault(Constant.PERMALINK_PATTERN_ANNO, DEFAULT_PERMALINK_PREFIX);

        String slug = UriUtils.encode(tag.getSpec().getSlug(), StandardCharsets.UTF_8);
        String path = PathUtils.combinePath(permalinkPrefix, slug);
        return externalUrlSupplier.get()
            .resolve(path)
            .normalize().toString();
    }
@Test
    void permalink() {
        Tag tag = new Tag();
        Metadata metadata = new Metadata();
        metadata.setName("test-tag");
        tag.setMetadata(metadata);
        Tag.TagSpec tagSpec = new Tag.TagSpec();
        tagSpec.setSlug("test-slug");
        tag.setSpec(tagSpec);

        when(externalUrlSupplier.get()).thenReturn(URI.create(""));

        String permalink = tagPermalinkPolicy.permalink(tag);
        assertThat(permalink).isEqualTo("/tags/test-slug");

        when(externalUrlSupplier.get()).thenReturn(URI.create("http://example.com"));

        permalink = tagPermalinkPolicy.permalink(tag);
        assertThat(permalink).isEqualTo("http://example.com/tags/test-slug");

        tag.getSpec().setSlug("中文slug");
        permalink = tagPermalinkPolicy.permalink(tag);
        assertThat(permalink).isEqualTo("http://example.com/tags/%E4%B8%AD%E6%96%87slug");
    }