Repository: goccy/go-yaml
Pull request #580 (2024-12-09 13:16:03)

Fix plain-url-in-flow-mapping
SSIA

codecov-commenter: :warning: Please install the !['codecov app svg image'](https://github.com/codecov/engineering-team/assets/152432831/e90313f4-9d3a-4b63-8b54-cfe14e7ec20d) to ensure uploads and comments are reliably processed by Codecov.

## [Codecov](https://app.codecov.io/gh/goccy/go-yaml/pull/580?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Masaaki+Goshima) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 77.43%. Comparing base [(`0e95011`)](https://app.codecov.io/gh/goccy/go-yaml/commit/0e95011a5dc7a437c31706dcf7840e0faa225ff0?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Masaaki+Goshima) to head [(`7a84d32`)](https://app.codecov.io/gh/goccy/go-yaml/commit/7a84d32d537dc6b19c5b345116989051e121d198?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Masaaki+Goshima).

:exclamation: Your organization needs to install the [Codecov GitHub app](https://github.com/apps/codecov/installations/select_target) to enable full functionality.

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master     #580      +/-   ##
==========================================
+ Coverage   77.42%   77.43%   +0.01%     
==========================================
  Files          21       21              
  Lines        7650     7654       +4     
==========================================
+ Hits         5923     5927       +4     
  Misses       1321     1321              
  Partials      406      406              
```

</details>

Patch:
diff --git a/scanner/scanner.go b/scanner/scanner.go
index 8da8123..db711a6 100644
--- a/scanner/scanner.go
+++ b/scanner/scanner.go
@@ -940,6 +940,10 @@ func (s *Scanner) scanMapDelim(ctx *Context) (bool, error) {
 	if s.startedFlowMapNum <= 0 && nc != ' ' && nc != '\t' && !s.isNewLineChar(nc) && !ctx.isNextEOS() {
 		return false, nil
 	}
+	if s.startedFlowMapNum > 0 && nc == '/' {
+		// like http://
+		return false, nil
+	}
 
 	if strings.HasPrefix(strings.TrimPrefix(string(ctx.obuf), " "), "\t") && !strings.HasPrefix(string(ctx.buf), "\t") {
 		invalidTk := token.Invalid("tab character cannot use as a map key directly", string(ctx.obuf), s.pos())


Test patch:
diff --git a/yaml_test_suite_test.go b/yaml_test_suite_test.go
index 187b39f..73cb459 100644
--- a/yaml_test_suite_test.go
+++ b/yaml_test_suite_test.go
@@ -51,7 +51,6 @@ var failureTestNames = []string{
 	"nested-implicit-complex-keys",                   // no json.
 	"node-anchor-not-indented",                       // pass yamlv3.
 	"plain-dashes-in-flow-sequence",
-	"plain-url-in-flow-mapping",                             // pass yamlv3.
 	"question-mark-edge-cases/00",                           // no json.
 	"question-mark-edge-cases/01",                           // no json.
 	"scalar-value-with-two-anchors",                         // pass yamlv3.